pub trait Unordered: Sized {
type Delta: Default;
// Required methods
fn diff(old: Self, new: Self) -> Option<Self::Delta>;
fn apply(&mut self, delta: Self::Delta);
}Expand description
A collection that can be diffed by membership alone.
Required Associated Types§
Required Methods§
Sourcefn diff(old: Self, new: Self) -> Option<Self::Delta>
fn diff(old: Self, new: Self) -> Option<Self::Delta>
Computes what it would take to turn old into new, or None when
the two hold the same elements.
The None mirrors Delta::delta: it is how a
field says it has nothing to contribute, so that a struct whose fields
all say so produces no delta at all.
Sourcefn apply(&mut self, delta: Self::Delta)
fn apply(&mut self, delta: Self::Delta)
Applies a membership diff in place.
Membership is preserved but position is not — additions land wherever
the collection decides to put them. Unlike
map::apply this cannot fail, because it never
recurses into Delta::apply_delta.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".