Ctx

Struct Ctx 

Source
pub struct Ctx<K, V>(/* private fields */);
Expand description

General BTreeMap context

Implementations§

Source§

impl<K: Ord, V> Ctx<K, V>

Special and wrapper methods for Ctx

Source

pub fn new() -> Self

Source

pub fn singleton(k: K, v: V) -> Self

Source

pub fn insert_with<FF>(&mut self, k: K, v1: V, f: &FF)
where V: Clone, FF: Fn(V, V) -> V,

Source

pub fn insert(&mut self, k: K, v: V)
where V: Clone,

Source

pub fn append_with<It, FF>(&mut self, it: It, f: &FF) -> &mut Self
where V: Clone, It: Iterator<Item = (K, V)>, FF: Fn(V, V) -> V,

Source

pub fn append<It>(&mut self, it: It) -> &mut Self
where V: Clone, It: Iterator<Item = (K, V)>,

Source

pub fn union_with<FF>(&self, other: Self, f: &FF) -> Self
where K: Clone, V: Clone, FF: Fn(V, V) -> V,

Source

pub fn union(&self, other: Self) -> Self
where K: Clone, V: Clone,

Source

pub fn intersection_with<VV, FF>(&self, other: Self, f: &FF) -> Ctx<K, VV>
where K: Clone, V: Clone, VV: Clone, FF: Fn(V, V) -> VV,

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, k: &K) -> Option<&V>

Source

pub fn get_mut(&mut self, k: &K) -> Option<&mut V>

Source

pub fn remove(&mut self, k: &K) -> Option<V>
where V: Clone,

Source

pub fn keys(&self) -> Set<&K>

Source

pub fn contains(&self, k: &K) -> bool

Source

pub fn iter(&self) -> CtxIterator<'_, K, V>

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>

Source

pub fn modify<F>(&mut self, f: F)
where F: FnMut(&K, &mut V),

Source

pub fn retain(&mut self, f: impl Fn(&K, &mut V) -> bool)

Source

pub fn extract_if(&mut self, f: impl Fn(&K, &V) -> bool) -> Ctx<K, V>
where K: Clone, V: Clone,

Trait Implementations§

Source§

impl<K: Clone, V: Clone> Clone for Ctx<K, V>

Source§

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

Returns a duplicate 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> Debug for Ctx<K, V>

Source§

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

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

impl<K: Ord, V> Default for Ctx<K, V>

Source§

fn default() -> Self

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

impl<'a, K, V> Display for Ctx<K, V>
where K: Pretty<'a, BoxAllocator, ()> + Clone, V: Pretty<'a, BoxAllocator, ()> + Clone,

Display instance for Ctx calls the pretty printer

Source§

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

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

impl<X, Y, K: From<X> + Ord, V: From<Y>, const N: usize> From<[(X, Y); N]> for Ctx<K, V>

From instance

Source§

fn from(v: [(X, Y); N]) -> Self

Converts to this type from the input type.
Source§

impl<K, V> FromIterator<(K, V)> for Ctx<K, V>
where K: Ord,

Source§

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

Creates a value from an iterator. Read more
Source§

impl<K: Hash, V: Hash> Hash for Ctx<K, V>

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<K, V> IntoIterator for Ctx<K, V>

IntoIterator instance for Ctx

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Ord, V: Ord> Ord for Ctx<K, V>

Source§

fn cmp(&self, other: &Ctx<K, V>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<K: PartialEq, V: PartialEq> PartialEq for Ctx<K, V>

Source§

fn eq(&self, other: &Ctx<K, V>) -> 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<K: PartialOrd, V: PartialOrd> PartialOrd for Ctx<K, V>

Source§

fn partial_cmp(&self, other: &Ctx<K, V>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, D, A, K, V> Pretty<'a, D, A> for Ctx<K, V>
where K: Clone + Pretty<'a, D, A>, V: Clone + Pretty<'a, D, A>, D: DocAllocator<'a, A>, D::Doc: Clone, A: 'a + Clone,

Pretty printer instance for Ctx

Source§

fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D, A>

Converts self into a document
Source§

impl<K: Eq, V: Eq> Eq for Ctx<K, V>

Source§

impl<K, V> StructuralPartialEq for Ctx<K, V>

Auto Trait Implementations§

§

impl<K, V> Freeze for Ctx<K, V>

§

impl<K, V> RefUnwindSafe for Ctx<K, V>

§

impl<K, V> Send for Ctx<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Ctx<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Ctx<K, V>

§

impl<K, V> UnwindSafe for Ctx<K, V>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.