Skip to content

Commit 9eeff6c

Browse files
author
Jesse Hoobergs
committed
Add implementation for Box
Taken from amethyst#37
1 parent e461da4 commit 9eeff6c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/implementation.rs

+24
Original file line numberDiff line numberDiff line change
@@ -409,3 +409,27 @@ impl<T: SerdeDiff + Serialize + for<'a> Deserialize<'a>> SerdeDiff for Option<T>
409409

410410
type Unit = ();
411411
opaque_serde_diff!(Unit);
412+
413+
impl<T> SerdeDiff for Box<T>
414+
where
415+
T: SerdeDiff,
416+
{
417+
fn diff<'a, S: SerializeSeq>(
418+
&self,
419+
ctx: &mut crate::difference::DiffContext<'a, S>,
420+
other: &Self,
421+
) -> Result<bool, S::Error> {
422+
self.as_ref().diff(ctx, other)
423+
}
424+
425+
fn apply<'de, A>(
426+
&mut self,
427+
seq: &mut A,
428+
ctx: &mut crate::apply::ApplyContext,
429+
) -> Result<bool, <A as serde::de::SeqAccess<'de>>::Error>
430+
where
431+
A: de::SeqAccess<'de>,
432+
{
433+
self.as_mut().apply(seq, ctx)
434+
}
435+
}

0 commit comments

Comments
 (0)