[−][src]Trait diff::Diff
A trait to diff and apply diffs between two structs The derive macro can be used on structs when all fields of the struct implement Diff Implementations are provided for bools, numeric types, Option types, and HashMaps
Associated Types
type Repr
The type associated with the structs' difference
Required methods
fn diff(&self, other: &Self) -> Self::Repr
Produces a diff between two structs
fn apply(&mut self, diff: &Self::Repr)
Applies the diff directly to the struct
fn identity() -> Self
The identity element of the struct
use diff::Diff; let s = 42; let i = <i32 as Diff>::identity(); assert_eq!(i.apply_new(&i.diff(&s)), s);
or mathematically speaking, i + (s - i) = s
Provided methods
fn diff_custom<D: Differ<Self>>(&self, other: &Self, visitor: &D) -> D::Repr
Produces a diff between two structs, using an external diffing implementation
fn apply_custom<D: Differ<Self>>(&mut self, diff: &D::Repr, visitor: &D)
Applies the diff directly to the struct, using an external diffing implementation
fn apply_new(&self, diff: &Self::Repr) -> Self
Applies the diff to the struct and produces a new struct
fn apply_new_custom<D: Differ<Self>>(&self, diff: &D::Repr, visitor: &D) -> Self
Applies the diff to the struct and produces a new struct, using an external diffing implementation
Implementations on Foreign Types
impl Diff for bool
[src]
type Repr = Option<bool>
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> Self
[src]
impl Diff for u8
[src]
type Repr = u8
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> u8
[src]
impl Diff for i8
[src]
type Repr = i8
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> i8
[src]
impl Diff for u16
[src]
type Repr = u16
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> u16
[src]
impl Diff for i16
[src]
type Repr = i16
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> i16
[src]
impl Diff for u32
[src]
type Repr = u32
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> u32
[src]
impl Diff for i32
[src]
type Repr = i32
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> i32
[src]
impl Diff for u64
[src]
type Repr = u64
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> u64
[src]
impl Diff for i64
[src]
type Repr = i64
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> i64
[src]
impl Diff for usize
[src]
type Repr = usize
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> usize
[src]
impl Diff for isize
[src]
type Repr = isize
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> isize
[src]
impl Diff for f32
[src]
type Repr = f32
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> f32
[src]
impl Diff for f64
[src]
type Repr = f64
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> f64
[src]
impl Diff for char
[src]
type Repr = Option<char>
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> Self
[src]
impl Diff for String
[src]
type Repr = Option<String>
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> Self
[src]
impl<T: Diff + PartialEq> Diff for Option<T>
[src]
type Repr = OptionDiff<T>
fn diff(&self, other: &Self) -> Self::Repr
[src]
fn apply(&mut self, diff: &Self::Repr)
[src]
fn identity() -> Self
[src]
impl<K: Hash + Eq, V: Diff> Diff for HashMap<K, V> where
K: Clone,
V: PartialEq,
[src]
K: Clone,
V: PartialEq,