pub struct Assoc<K, V>{ /* private fields */ }Expand description
A persistent key-value store. clone, set, and find are sub-linear.
Implementations§
Source§impl<K: Eq + Hash + Clone, V: Clone> Assoc<K, V>
impl<K: Eq + Hash + Clone, V: Clone> Assoc<K, V>
pub fn new() -> Self
pub fn find(&self, key: &K) -> Option<&V>
pub fn set(&self, key: K, value: V) -> Self
pub fn set_assoc(&self, other: &Self) -> Self
pub fn mut_set(&mut self, key: K, value: V)
pub fn single(key: K, value: V) -> Self
pub fn empty(&self) -> bool
pub fn iter_pairs(&self) -> Iter<'_, K, V>
pub fn iter_keys(&self) -> Keys<'_, K, V>
pub fn iter_values(&self) -> Values<'_, K, V>
pub fn map<NewV: Clone, F>(&self, f: F) -> Assoc<K, NewV>
pub fn map_borrow_f<'assoc, NewV: Clone, F>( &'assoc self, f: &mut F, ) -> Assoc<K, NewV>
pub fn keyed_map_borrow_f<NewV: Clone, F>(&self, f: &mut F) -> Assoc<K, NewV>
pub fn map_with<OtherV: Clone, NewV: Clone>( &self, other: &Assoc<K, OtherV>, f: &dyn Fn(&V, &OtherV) -> NewV, ) -> Assoc<K, NewV>
pub fn keyed_map_with<OtherV: Clone, NewV: Clone>( &self, other: &Assoc<K, OtherV>, f: &dyn Fn(&K, &V, &OtherV) -> NewV, ) -> Assoc<K, NewV>
pub fn find_value<'assoc, 'f>(&'assoc self, target: &'f V) -> Option<&'assoc K>where
V: PartialEq,
pub fn find_or_panic<'assoc, 'f>(&'assoc self, target: &'f K) -> &'assoc Vwhere
K: Display,
pub fn remove<'assoc, 'f>(&'assoc mut self, target: &'f K) -> Option<V>
pub fn remove_or_panic<'assoc, 'f>(&'assoc mut self, target: &'f K) -> Vwhere
K: Display,
pub fn cut_common(&self, other: &Assoc<K, V>) -> Assoc<K, V>where
V: PartialEq,
pub fn unset(&self, k: &K) -> Assoc<K, V>
pub fn reduce<Out>(&self, red: &dyn Fn(&K, &V, Out) -> Out, base: Out) -> Out
Source§impl<K: Eq + Hash + Clone, V: Clone> Assoc<K, V>
impl<K: Eq + Hash + Clone, V: Clone> Assoc<K, V>
pub fn almost_ptr_eq(&self, other: &Assoc<K, V>) -> bool
Source§impl<K: Eq + Hash + Clone, V: Clone, E: Clone> Assoc<K, Result<V, E>>
impl<K: Eq + Hash + Clone, V: Clone, E: Clone> Assoc<K, Result<V, E>>
pub fn lift_result(self) -> Result<Assoc<K, V>, E>
Source§impl<T: Clone> Assoc<Name, Asterism<T>>
impl<T: Clone> Assoc<Name, Asterism<T>>
pub fn new_from_leaves(l: Assoc<Name, T>) -> Self
pub fn new_from_named_repeat(_n: Name, r: Vec<Self>) -> Self
👎Deprecated
pub fn new_from_anon_repeat(r: Vec<Self>) -> Self
pub fn leaf(&self, n: Name) -> &T
pub fn depth_1<'b>(&'b self, n: Name) -> Box<dyn Iterator<Item = &'b T> + 'b>
pub fn to_sky_slices<'b>(&'b self) -> Assoc<Name, AsterismSlice<'b, T>>
pub fn march<'b>( &'b self, driving_names: &'b [Name], ) -> Box<dyn Iterator<Item = Assoc<Name, AsterismSlice<'b, T>>> + 'b>
pub fn add_leaf(&mut self, n: Name, v: T)
pub fn add_named_repeat(&mut self, _: Name, sub: Vec<Assoc<Name, Asterism<T>>>)
👎Deprecated: inefficent, and named repeats are gone
pub fn add_anon_repeat(&mut self, sub: Vec<Assoc<Name, Asterism<T>>>)
👎Deprecated: inefficent
pub fn anonimize_repeat(&mut self, _: Name)
👎Deprecated: named repeats are gone
Trait Implementations§
Source§impl<K: Eq + Hash + Clone + Reifiable, V: Clone + Reifiable> Reifiable for Assoc<K, V>
impl<K: Eq + Hash + Clone + Reifiable, V: Clone + Reifiable> Reifiable for Assoc<K, V>
Source§fn ty_name() -> Name
fn ty_name() -> Name
A name for that type, so that recursive types are okay.
Ignore the type parameters of
Self; invoke like Self::<Irr,Irr>::ty_name().
e.g. WithIntegerfn concrete_arguments() -> Option<Vec<Ast>>
Source§fn ty() -> Ast
fn ty() -> Ast
The Unseemly type that corresponds to to the
Reifiable type.
This leaves abstract the type parameters of Self; invoke like Self::<Irr,Irr>::ty().
e.g. ∀ A. Pair<A int>
TODO: rename to generic_tySource§fn ty_invocation() -> Ast
fn ty_invocation() -> Ast
How to refer to this type, given an environment in which
ty_name() is defined to be ty().
Parameters will be concrete.
e.g. WithInteger<Float>
(Types using this type will use this, rather than ty)
Don’t override this.impl<K: Eq + Hash + Clone, V: Clone + Eq> Eq for Assoc<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Assoc<K, V>
impl<K, V> RefUnwindSafe for Assoc<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Send for Assoc<K, V>
impl<K, V> !Sync for Assoc<K, V>
impl<K, V> Unpin for Assoc<K, V>
impl<K, V> UnwindSafe for Assoc<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.