Struct ChainMap

Source
pub struct ChainMap<K, V, S = RandomState> { /* private fields */ }

Implementations§

Source§

impl<K, V, S> ChainMap<K, V, S>
where K: Hash + Eq, S: BuildHasher,

Source

pub fn new(map: HashMap<K, V, S>) -> Self

Source

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Inserts a key-value pair into the map. If the map did not have this key present, None is returned.

Source

pub fn insert_at( &mut self, idx: usize, key: K, value: V, ) -> Result<Option<V>, Error>

Source

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

Returns the key-value pair corresponding to the supplied key.

The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Source

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

Returns a mutable reference to the value corresponding to the key.

The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Source

pub fn get_before<Q>(&self, idx: usize, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn get_before_mut<Q>(&mut self, idx: usize, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn new_child_with(&mut self, map: HashMap<K, V, S>)

Source

pub fn last_has<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn has_at<Q>(&self, idx: usize, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn child_len(&self) -> usize

Source

pub fn get_last_index<Q>(&self, key: &Q) -> Option<usize>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

impl<K: Hash + Eq, V, S: BuildHasher + Default> ChainMap<K, V, S>

Source

pub fn new_child(&mut self)

Source

pub fn remove_child(&mut self) -> Option<HashMap<K, V, S>>

Source

pub fn split_off(&mut self, idx: usize) -> Self

Source

pub fn append(&mut self, other: &mut Self)

Trait Implementations§

Source§

impl<K: Clone, V: Clone, S: Clone> Clone for ChainMap<K, V, S>

Source§

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

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, V, S> Debug for ChainMap<K, V, S>
where K: Eq + Hash + Debug, V: Debug, S: BuildHasher,

Source§

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

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

impl<K, V> Default for ChainMap<K, V>
where K: Hash + Eq,

Source§

fn default() -> Self

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

impl<K, Q, V, S> Index<&Q> for ChainMap<K, V, S>
where K: Eq + Hash + Borrow<Q>, Q: Eq + Hash + ?Sized, S: BuildHasher,

Source§

fn index(&self, key: &Q) -> &V

Returns a reference to the value corresponding to the supplied key.

§Panics

Panics if the key is not present in the HashMap.

Source§

type Output = V

The returned type after indexing.
Source§

impl<K, V, S> PartialEq for ChainMap<K, V, S>
where K: Eq + Hash, V: PartialEq, S: BuildHasher,

Source§

fn eq(&self, other: &ChainMap<K, V, S>) -> 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, V, S> Eq for ChainMap<K, V, S>
where K: Eq + Hash, V: Eq, S: BuildHasher,

Auto Trait Implementations§

§

impl<K, V, S> Freeze for ChainMap<K, V, S>

§

impl<K, V, S> RefUnwindSafe for ChainMap<K, V, S>

§

impl<K, V, S> Send for ChainMap<K, V, S>
where S: Send, K: Send, V: Send,

§

impl<K, V, S> Sync for ChainMap<K, V, S>
where S: Sync, K: Sync, V: Sync,

§

impl<K, V, S> Unpin for ChainMap<K, V, S>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<K, V, S> UnwindSafe for ChainMap<K, V, S>
where K: UnwindSafe, V: UnwindSafe, S: UnwindSafe,

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