Struct mergable::Dict

source ·
pub struct Dict<K, V, Seq> { /* private fields */ }
Expand description

A mergable dictionary.

This dict must contain a Mergable value. This determines the semantics on conflict. For example if the value is a Cell then last-write-wins semantics will be used. However if the value is a Bag then multiple values inserted into the same key will be kept. If the value is a Counter than conflicting values will be summed.

Implementations§

source§

impl<K: Clone + Eq + Hash, V: Mergable, SF: SequenceFactory> Dict<K, V, Sequence<SF>>

source

pub fn entry(&mut self, key: K) -> DictEntry<'_, K, V, SF>

source

pub fn get<Q: Hash + Eq>(&self, k: &Q) -> Option<&V>where K: Borrow<Q>,

source

pub fn get_mut<Q: Hash + Eq>(&mut self, k: &Q) -> Option<&mut V>where K: Borrow<Q>,

source

pub fn insert(&mut self, ctx: &mut Context<SF>, k: K, v: V)

Insert a value into the map.

  • Note that if the value is already in the map the two values will be merged. If you do not want this to occur delete the value first.

  • Also note that this updates the key’s creation time meaning that deletes on the previous key will no longer be respected.

  • TODO: Weird revival stuff.

source

pub fn remove<Q>(&mut self, ctx: &mut Context<SF>, k: K) -> Option<V>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Remove a value from the map.

Note that the semantics of this operation can be confusing read the description carefully.

This removes the known version of the element in the map and all older versions. Unknown modifications will not prevent deletion but if the element has been inserted again after the version that we are aware of that insert will be preserved. Also note that due to merging semantics that may result in values from the known version “reappearing”.

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn iter(&self) -> DictIter<'_, K, V, Sequence<SF>>

Trait Implementations§

source§

impl<K: Clone, V: Clone, Seq: Clone> Clone for Dict<K, V, Seq>

source§

fn clone(&self) -> Dict<K, V, Seq>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<K: Debug, V: Debug, Seq> Debug for Dict<K, V, Seq>

source§

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

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

impl<K, V, SF> Default for Dict<K, V, SF>

source§

fn default() -> Self

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

impl<'a, K: Clone + Eq + Hash, V: Mergable, SF: SequenceFactory> IntoIterator for &'a Dict<K, V, Sequence<SF>>

§

type IntoIter = DictIter<'a, K, V, Sequence<SF>>

Which kind of iterator are we turning this into?
§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: Clone + Eq + Hash, V: Mergable, SF: SequenceFactory> IntoIterator for Dict<K, V, Sequence<SF>>

§

type IntoIter = DictIntoIter<K, V, Sequence<SF>>

Which kind of iterator are we turning this into?
§

type Item = (K, V)

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: Clone + Eq + Hash, V: Clone + Mergable<Seq = Sequence<SF>>, SF: SequenceFactory> Mergable for Dict<K, V, Sequence<SF>>

§

type Diff = DictDiff<K, V, Sequence<SF>>

§

type Seq = Sequence<SF>

source§

fn merge(&mut self, that: Self)

source§

fn diff(&self, that: &Self) -> Self::Diff

Produce a diff. Read more
source§

fn apply(&mut self, diff: Self::Diff) -> Result<(), ApplyError>

source§

fn clean(&mut self, cutoff: &Self::Seq)

Clean up history. Read more
source§

impl<K: Eq + Hash, V: PartialEq, Seq> PartialEq<Dict<K, V, Seq>> for Dict<K, V, Seq>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<K, V, Seq> RefUnwindSafe for Dict<K, V, Seq>where K: RefUnwindSafe, Seq: RefUnwindSafe, V: RefUnwindSafe,

§

impl<K, V, Seq> Send for Dict<K, V, Seq>where K: Send, Seq: Send, V: Send,

§

impl<K, V, Seq> Sync for Dict<K, V, Seq>where K: Sync, Seq: Sync, V: Sync,

§

impl<K, V, Seq> Unpin for Dict<K, V, Seq>where K: Unpin, Seq: Unpin, V: Unpin,

§

impl<K, V, Seq> UnwindSafe for Dict<K, V, Seq>where K: UnwindSafe, Seq: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V