Skip to content

Commit

Permalink
Add implementation for Box
Browse files Browse the repository at this point in the history
Taken from amethyst#37
  • Loading branch information
Jesse Hoobergs committed Jan 18, 2022
1 parent e461da4 commit 9eeff6c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,27 @@ impl<T: SerdeDiff + Serialize + for<'a> Deserialize<'a>> SerdeDiff for Option<T>

type Unit = ();
opaque_serde_diff!(Unit);

impl<T> SerdeDiff for Box<T>
where
T: SerdeDiff,
{
fn diff<'a, S: SerializeSeq>(
&self,
ctx: &mut crate::difference::DiffContext<'a, S>,
other: &Self,
) -> Result<bool, S::Error> {
self.as_ref().diff(ctx, other)
}

fn apply<'de, A>(
&mut self,
seq: &mut A,
ctx: &mut crate::apply::ApplyContext,
) -> Result<bool, <A as serde::de::SeqAccess<'de>>::Error>
where
A: de::SeqAccess<'de>,
{
self.as_mut().apply(seq, ctx)
}
}

0 comments on commit 9eeff6c

Please sign in to comment.