BTreeSetDiff

Struct BTreeSetDiff 

Source
pub struct BTreeSetDiff<'daft, K: Ord + Eq> {
    pub common: BTreeSet<&'daft K>,
    pub added: BTreeSet<&'daft K>,
    pub removed: BTreeSet<&'daft K>,
}
Available on crate feature alloc only.
Expand description

A diff of two BTreeSet instances.

The diff contains three elements:

  • common: Entries that are present in both sets.
  • added: Entries present in after, but not in before.
  • removed: Entries present in before, but not in after.

§Example

use daft::{BTreeSetDiff, Diffable};
use std::collections::BTreeSet;

let a: BTreeSet<usize> = [0, 1].into_iter().collect();
let b: BTreeSet<usize> = [1, 2].into_iter().collect();

let changes = a.diff(&b);
let expected = BTreeSetDiff {
    // Entries are stored by reference and matched by equality.
    common: [&1].into_iter().collect(),
    added: [&2].into_iter().collect(),
    removed: [&0].into_iter().collect(),
};

assert_eq!(changes, expected);

Fields§

§common: BTreeSet<&'daft K>

Entries common to both sets.

§added: BTreeSet<&'daft K>

Entries present in the after set, but not in before.

§removed: BTreeSet<&'daft K>

Entries present in the before set, but not in after.

Implementations§

Source§

impl<'daft, K: Ord + Eq> BTreeSetDiff<'daft, K>

Source

pub fn new() -> Self

Create a new, empty BTreeSetDiff instance.

Trait Implementations§

Source§

impl<'daft, K: Debug + Ord + Eq> Debug for BTreeSetDiff<'daft, K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'daft, K: Ord + Eq> Default for BTreeSetDiff<'daft, K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'daft, K: PartialEq + Ord + Eq> PartialEq for BTreeSetDiff<'daft, K>

Source§

fn eq(&self, other: &BTreeSetDiff<'daft, K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'daft, K: Eq + Ord + Eq> Eq for BTreeSetDiff<'daft, K>

Source§

impl<'daft, K: Ord + Eq> StructuralPartialEq for BTreeSetDiff<'daft, K>

Auto Trait Implementations§

§

impl<'daft, K> Freeze for BTreeSetDiff<'daft, K>

§

impl<'daft, K> RefUnwindSafe for BTreeSetDiff<'daft, K>
where K: RefUnwindSafe,

§

impl<'daft, K> Send for BTreeSetDiff<'daft, K>
where K: Sync,

§

impl<'daft, K> Sync for BTreeSetDiff<'daft, K>
where K: Sync,

§

impl<'daft, K> Unpin for BTreeSetDiff<'daft, K>

§

impl<'daft, K> UnwindSafe for BTreeSetDiff<'daft, K>
where K: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.