pub struct AutoMap<K, V> { /* private fields */ }
Expand description
A structure similar to HashMap
but allows to provide a function create
for creating a new value if particular key doesn’t exists.
Such a function can for example fetch data from internet.
use vertigo::AutoMap;
let my_map = AutoMap::<i32, i32>::new(|_, x| x*2);
assert_eq!(my_map.get(&5), 10);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for AutoMap<K, V>
impl<K, V> !RefUnwindSafe for AutoMap<K, V>
impl<K, V> !Send for AutoMap<K, V>
impl<K, V> !Sync for AutoMap<K, V>
impl<K, V> Unpin for AutoMap<K, V>
impl<K, V> !UnwindSafe for AutoMap<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