pub struct OnceMap<K, V, S = RandomState> { /* private fields */ }
Implementations§
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
Sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates an empty OnceMap
which will use the given hash builder to hash keys.
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all key-value pairs from the map, but keeps the allocated memory.
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>
pub fn into_iter(self) -> impl Iterator<Item = (K, V)>
Sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
Sourcepub fn read_only_view(&self) -> ReadOnlyView<'_, K, V, S>
pub fn read_only_view(&self) -> ReadOnlyView<'_, K, V, S>
Locks the whole map for reading.
This enables more methods, such as iterating on the maps, but will cause a deadlock if trying to insert values in the map from the same thread.
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
pub fn into_par_iter(self) -> impl ParallelIterator<Item = (K, V)>
Available on crate feature
rayon
only.Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
pub fn get_cloned<Q>(&self, key: &Q) -> Option<V>
pub fn insert_cloned(&self, key: K, make_val: impl FnOnce(&K) -> V) -> V
pub fn try_insert_cloned<E>( &self, key: K, make_val: impl FnOnce(&K) -> Result<V, E>, ) -> Result<V, E>
Source§impl<K, V, S> OnceMap<K, V, S>
impl<K, V, S> OnceMap<K, V, S>
pub fn map_get<Q, T>( &self, key: &Q, with_result: impl FnOnce(&K, &V) -> T, ) -> Option<T>
pub fn map_insert<T>( &self, key: K, make_val: impl FnOnce(&K) -> V, with_result: impl FnOnce(&K, &V) -> T, ) -> T
pub fn map_insert_ref<Q, T>( &self, key: &Q, make_key: impl FnOnce(&Q) -> K, make_val: impl FnOnce(&K) -> V, with_result: impl FnOnce(&K, &V) -> T, ) -> T
pub fn map_try_insert<T, E>( &self, key: K, make_val: impl FnOnce(&K) -> Result<V, E>, with_result: impl FnOnce(&K, &V) -> T, ) -> Result<T, E>
pub fn map_try_insert_ref<Q, T, E>( &self, key: &Q, make_key: impl FnOnce(&Q) -> K, make_val: impl FnOnce(&K) -> Result<V, E>, with_result: impl FnOnce(&K, &V) -> T, ) -> Result<T, E>
pub fn get_or_try_insert<T, U, E>( &self, key: K, data: T, on_vacant: impl FnOnce(T, &K) -> Result<(V, U), E>, on_occupied: impl FnOnce(T, &K, &V) -> U, ) -> Result<U, E>
pub fn get_or_try_insert_ref<Q, T, U, E>( &self, key: &Q, data: T, make_key: impl FnOnce(&Q) -> K, on_vacant: impl FnOnce(T, &K) -> Result<(V, U), E>, on_occupied: impl FnOnce(T, &K, &V) -> U, ) -> Result<U, E>
Trait Implementations§
Source§impl<'de, K, V, S> Deserialize<'de> for OnceMap<K, V, S>
Available on crate feature serde
only.
impl<'de, K, V, S> Deserialize<'de> for OnceMap<K, V, S>
Available on crate feature
serde
only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, V, S> Extend<(K, V)> for &OnceMap<K, V, S>
impl<K, V, S> Extend<(K, V)> for &OnceMap<K, V, S>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K, V, S> Extend<(K, V)> for OnceMap<K, V, S>
impl<K, V, S> Extend<(K, V)> for OnceMap<K, V, S>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K, V, S> FromIterator<(K, V)> for OnceMap<K, V, S>
impl<K, V, S> FromIterator<(K, V)> for OnceMap<K, V, S>
Source§impl<K, V, S> FromParallelIterator<(K, V)> for OnceMap<K, V, S>
Available on crate feature rayon
only.
impl<K, V, S> FromParallelIterator<(K, V)> for OnceMap<K, V, S>
Available on crate feature
rayon
only.Source§fn from_par_iter<I>(par_iter: I) -> Selfwhere
I: IntoParallelIterator<Item = (K, V)>,
fn from_par_iter<I>(par_iter: I) -> Selfwhere
I: IntoParallelIterator<Item = (K, V)>,
Creates an instance of the collection from the parallel iterator
par_iter
. Read moreSource§impl<K, V, S> ParallelExtend<(K, V)> for &OnceMap<K, V, S>
Available on crate feature rayon
only.
impl<K, V, S> ParallelExtend<(K, V)> for &OnceMap<K, V, S>
Available on crate feature
rayon
only.Source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
Extends an instance of the collection with the elements drawn
from the parallel iterator
par_iter
. Read moreSource§impl<K, V, S> ParallelExtend<(K, V)> for OnceMap<K, V, S>
Available on crate feature rayon
only.
impl<K, V, S> ParallelExtend<(K, V)> for OnceMap<K, V, S>
Available on crate feature
rayon
only.Source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
Extends an instance of the collection with the elements drawn
from the parallel iterator
par_iter
. Read moreAuto Trait Implementations§
impl<K, V, S> Freeze for OnceMap<K, V, S>where
S: Freeze,
impl<K, V, S = RandomState> !RefUnwindSafe for OnceMap<K, V, S>
impl<K, V, S> Send for OnceMap<K, V, S>
impl<K, V, S> Sync for OnceMap<K, V, S>
impl<K, V, S> Unpin for OnceMap<K, V, S>where
S: Unpin,
impl<K, V, S = RandomState> !UnwindSafe for OnceMap<K, V, S>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more