[−][src]Trait hashmap_entry_ownable::EntryAPI
Required methods
fn entry_ownable<'a, 'q>(&'a mut self, key: &'q Q) -> Entry<'a, 'q, K, Q, V, S>
Gets the given key's corresponding entry in the map for in-place manipulation, creating copy of the key if necessary.
The 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.
Examples
use std::collections::HashMap; use hashmap_entry_ownable::EntryAPI; let mut words: HashMap<String, _> = HashMap::new(); let rhyme = vec![ "Mary", "had", "a", "little", "lamb", "little", "lamb", "little", "lamb", ]; for w in rhyme { let counter = words.entry_ownable(w).or_insert(0); *counter += 1; } assert_eq!(words["Mary"], 1); assert_eq!(words["lamb"], 3); assert_eq!(words.get("fleece"), None);
Implementations on Foreign Types
impl<K, Q: ?Sized, V, S> EntryAPI<K, Q, V, S> for HashMap<K, V, S> where
K: Borrow<Q> + Hash + Eq,
Q: ToOwned<Owned = K> + Hash + Eq,
S: BuildHasher,
[src]
K: Borrow<Q> + Hash + Eq,
Q: ToOwned<Owned = K> + Hash + Eq,
S: BuildHasher,