pub struct LazyMap<K, V, S = RandomState, F = fn(&K) -> V> { /* private fields */ }Expand description
A map where values are automatically filled at access.
This type has less overhead than crate::sync::LazyMap but it cannot be
shared across threads.
let map = once_map::unsync::LazyMap::new(|x: &i32| x.to_string());
assert_eq!(&map[&3], "3");
assert_eq!(map.get(&-67), "-67");Implementations§
Source§impl<K, V, S, F> LazyMap<K, V, S, F>
impl<K, V, S, F> LazyMap<K, V, S, F>
pub const fn with_hasher(hash_builder: S, f: F) -> Self
Trait Implementations§
Source§impl<K, V: Default, S: Default> Default for LazyMap<K, V, S>
Creates a LazyMap that fills all values with V::default().
impl<K, V: Default, S: Default> Default for LazyMap<K, V, S>
Creates a LazyMap that fills all values with V::default().
Source§impl<K, V, S, F, Q> Index<&Q> for LazyMap<K, V, S, F>where
K: Eq + Hash,
S: BuildHasher,
F: Fn(&K) -> V,
V: StableDeref,
Q: Hash + ToOwnedEquivalent<K> + ?Sized,
impl<K, V, S, F, Q> Index<&Q> for LazyMap<K, V, S, F>where
K: Eq + Hash,
S: BuildHasher,
F: Fn(&K) -> V,
V: StableDeref,
Q: Hash + ToOwnedEquivalent<K> + ?Sized,
Auto Trait Implementations§
impl<K, V, S = RandomState, F = fn(&K) -> V> !Freeze for LazyMap<K, V, S, F>
impl<K, V, S = RandomState, F = fn(&K) -> V> !RefUnwindSafe for LazyMap<K, V, S, F>
impl<K, V, S, F> Send for LazyMap<K, V, S, F>
impl<K, V, S = RandomState, F = fn(&K) -> V> !Sync for LazyMap<K, V, S, F>
impl<K, V, S, F> Unpin for LazyMap<K, V, S, F>
impl<K, V, S, F> UnwindSafe for LazyMap<K, V, S, F>
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