Skip to main content

Change

Struct Change 

Source
pub struct Change<T, K> { /* private fields */ }
Expand description

A change of one item of a cache (Change<TObject, TKey>): its reason, its key, the item and, for an update, the item it replaced; the indexes for a sorted collection.

Deviation (DEVIATIONS.md, DynamicData): the indexes are Option<usize>, where upstream writes -1 for no index.

Implementations§

Source§

impl<T, K> Change<T, K>

Source

pub fn new(reason: ChangeReason, key: K, current: T) -> Self

A change without a previous item (Change(ChangeReason, TKey, TObject, int index = -1)).

§Panics

For ChangeReason::Update, which needs the previous item (ArgumentException).

Source

pub fn with_index( reason: ChangeReason, key: K, current: T, index: Option<usize>, ) -> Self

A change with the index of the item (Change(ChangeReason, TKey, TObject, int index)).

Source

pub fn with_previous( reason: ChangeReason, key: K, current: T, previous: Option<T>, current_index: Option<usize>, previous_index: Option<usize>, ) -> Self

A change with every part (Change(ChangeReason, TKey, TObject, in Optional<TObject>, int, int)).

§Panics

For ChangeReason::Add with a previous item, and for ChangeReason::Update without one (ArgumentException).

Source

pub fn update(key: K, current: T, previous: T) -> Self

An update of key from previous to current (Change(ChangeReason.Update, key, current, previous)).

Source

pub fn moved( key: K, current: T, current_index: usize, previous_index: usize, ) -> Self

A move within a sorted collection (Change(TKey, TObject, int currentIndex, int previousIndex)).

Source

pub fn key(&self) -> &K

The key of the item (Key).

Source

pub fn reason(&self) -> ChangeReason

The reason of the change (Reason).

Source

pub fn current(&self) -> &T

The item (Current).

Source

pub fn previous(&self) -> Option<&T>

The item that an update replaced (Previous).

Source

pub fn current_index(&self) -> Option<usize>

The index of the item in a sorted collection (CurrentIndex; -1 upstream when none).

Source

pub fn previous_index(&self) -> Option<usize>

The previous index of the item (PreviousIndex).

Source

pub fn into_parts(self) -> (ChangeReason, K, T, Option<T>)

The parts of the change, taken apart.

Trait Implementations§

Source§

impl<T: Clone, K: Clone> Clone for Change<T, K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, K: Debug> Debug for Change<T, K>

Source§

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

ToString: the reason, the key, the item and the previous item.

Source§

impl<T: Eq, K: Eq> Eq for Change<T, K>

Source§

impl<T, K> FromIterator<Change<T, K>> for ChangeSet<T, K>

Source§

fn from_iter<I: IntoIterator<Item = Change<T, K>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash, K: Hash> Hash for Change<T, K>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq, K: PartialEq> PartialEq for Change<T, K>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq, K: PartialEq> StructuralPartialEq for Change<T, K>

Auto Trait Implementations§

§

impl<T, K> Freeze for Change<T, K>
where K: Freeze, T: Freeze, Option<T>: Freeze,

§

impl<T, K> RefUnwindSafe for Change<T, K>

§

impl<T, K> Send for Change<T, K>
where K: Send, T: Send, Option<T>: Send,

§

impl<T, K> Sync for Change<T, K>
where K: Sync, T: Sync, Option<T>: Sync,

§

impl<T, K> Unpin for Change<T, K>
where K: Unpin, T: Unpin, Option<T>: Unpin,

§

impl<T, K> UnsafeUnpin for Change<T, K>

§

impl<T, K> UnwindSafe for Change<T, K>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.