Trait StructDiffer

Source
pub trait StructDiffer {
    type Ok;
    type Err;

    // Required methods
    fn diff_field<T>(&mut self, name: &'static str, a: &T, b: &T)
       where T: Diff + ?Sized;
    fn end(self) -> Result<Self::Ok, Self::Err>;

    // Provided method
    fn skip_field<T: ?Sized>(&mut self, _name: &'static str) { ... }
}
Expand description

A type that can deal with differences in a struct.

Required Associated Types§

Source

type Ok

Type returned on success.

Source

type Err

Type returned on failure.

Required Methods§

Source

fn diff_field<T>(&mut self, name: &'static str, a: &T, b: &T)
where T: Diff + ?Sized,

Visits a field name with values a and b in the respective structures.

Source

fn end(self) -> Result<Self::Ok, Self::Err>

Completes traversal of the struct.

Provided Methods§

Source

fn skip_field<T: ?Sized>(&mut self, _name: &'static str)

Skips a field that is excluded from differencing.

Some differs may e.g. print a placeholder for skipped fields.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl StructDiffer for ()

Source§

type Ok = ()

Source§

type Err = Void

Source§

fn diff_field<T>(&mut self, _: &'static str, _: &T, _: &T)
where T: Diff + ?Sized,

Source§

fn end(self) -> Result<Self::Ok, Self::Err>

Implementors§