HashSetDiff

Struct HashSetDiff 

Source
pub struct HashSetDiff<'daft, K: Hash + Eq> {
    pub common: HashSet<&'daft K>,
    pub added: HashSet<&'daft K>,
    pub removed: HashSet<&'daft K>,
}
Available on crate feature std only.
Expand description

A diff of two HashSet 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::{Diffable, HashSetDiff};
use std::collections::HashSet;

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

let changes = a.diff(&b);
let expected = HashSetDiff {
    // 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: HashSet<&'daft K>

Entries common to both sets.

§added: HashSet<&'daft K>

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

§removed: HashSet<&'daft K>

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

Implementations§

Source§

impl<'daft, K: Hash + Eq> HashSetDiff<'daft, K>

Source

pub fn new() -> Self

Create a new, empty HashSetDiff instance.

Trait Implementations§

Source§

impl<'daft, K: Debug + Hash + Eq> Debug for HashSetDiff<'daft, K>

Source§

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

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

impl<'daft, K: Hash + Eq> Default for HashSetDiff<'daft, K>

Source§

fn default() -> Self

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

impl<'daft, K: PartialEq + Hash + Eq> PartialEq for HashSetDiff<'daft, K>

Source§

fn eq(&self, other: &HashSetDiff<'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 + Hash + Eq> Eq for HashSetDiff<'daft, K>

Source§

impl<'daft, K: Hash + Eq> StructuralPartialEq for HashSetDiff<'daft, K>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'daft, K> UnwindSafe for HashSetDiff<'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.