diffus/diffable_impls/
primitives.rs1use crate::{edit, Diffable};
2
3macro_rules! primitive_impl {
4 ($($typ:ty),*) => {
5 $(
6 impl<'a> Diffable<'a> for $typ {
7 type Diff = (&'a $typ, &'a $typ);
8
9 fn diff(&'a self, other: &'a Self) -> edit::Edit<Self> {
10 use crate::Same;
11 if self.same(other) {
12 edit::Edit::Copy(self)
13 } else {
14 edit::Edit::Change((self, other))
15 }
16 }
17 }
18 )*
19 }
20}
21
22primitive_impl! { i64, i32, i16, i8, u64, u32, u16, u8, char, bool, isize, usize, f32, f64, () }
23
24#[cfg(feature = "uuid-impl")]
25primitive_impl! { uuid::Uuid }
26
27#[cfg(feature = "snake_case-impl")]
28primitive_impl! { snake_case::SnakeCase }