Skip to main content

Unordered

Trait Unordered 

Source
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§

Source

type Delta: Default

The shape a membership diff of this collection takes.

Required Methods§

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl<K, V, S> Unordered for HashMap<K, V, S>
where K: Hash + Eq, V: PartialEq, S: BuildHasher,

Source§

type Delta = EntryDelta<K, V>

Source§

fn diff(old: Self, new: Self) -> Option<EntryDelta<K, V>>

Source§

fn apply(&mut self, delta: EntryDelta<K, V>)

Source§

impl<K, V> Unordered for BTreeMap<K, V>
where K: Ord, V: PartialEq,

Source§

type Delta = EntryDelta<K, V>

Source§

fn diff(old: Self, new: Self) -> Option<EntryDelta<K, V>>

Source§

fn apply(&mut self, delta: EntryDelta<K, V>)

Source§

impl<T, S> Unordered for HashSet<T, S>
where T: Hash + Eq, S: BuildHasher,

Source§

type Delta = BagDelta<T>

Source§

fn diff(old: Self, new: Self) -> Option<BagDelta<T>>

Source§

fn apply(&mut self, delta: BagDelta<T>)

Source§

impl<T> Unordered for BTreeSet<T>
where T: Ord,

Source§

type Delta = BagDelta<T>

Source§

fn diff(old: Self, new: Self) -> Option<BagDelta<T>>

Source§

fn apply(&mut self, delta: BagDelta<T>)

Implementors§