pub struct CaseInsensitiveHashMap<V, S = RandomState>where
S: BuildHasher,{ /* private fields */ }
Implementations§
source§impl<V> CaseInsensitiveHashMap<V, RandomState>
impl<V> CaseInsensitiveHashMap<V, RandomState>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new CaseInsensitiveHashMap with the default hasher and capacity.
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut map = CaseInsensitiveHashMap::new();
map.insert("A", 1);
map.insert("B", 2);
map.insert("a", 10);
for (k,v) in &map {
println!("Key = {}, Value = {}", k, v);
}
if map.contains_key("c") {
println!("c is in the map");
} else {
println!("c is NOT in the map");
}
for (k,v) in &mut map {
*v *= 10;
println!("Key = {}, Value = {}", k, v);
}
let keys = map.keys().collect::<Vec<_>>();
println!("keys = {:?}", keys);
let values = map.values().collect::<Vec<_>>();
println!("values = {:?}", values);
}
sourcepub fn with_capacity(capacity: usize) -> CaseInsensitiveHashMap<V, RandomState>
pub fn with_capacity(capacity: usize) -> CaseInsensitiveHashMap<V, RandomState>
Creates a new CaseInsensitiveHashMap with the default hasher and specified capacity.
source§impl<V, S> CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
impl<V, S> CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates a new CaseInsensitiveHashMap with the specified hasher and default capacity.
sourcepub fn with_capacity_and_hasher(
capacity: usize,
hash_builder: S,
) -> CaseInsensitiveHashMap<V, S>
pub fn with_capacity_and_hasher( capacity: usize, hash_builder: S, ) -> CaseInsensitiveHashMap<V, S>
Creates a new CaseInsensitiveHashMap with the specified capacity and hasher.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
This number is a lower bound; the HashMap might be able to hold more, but is guaranteed to be able to hold at least this many.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
sourcepub fn contains_key<K: Into<UniCase<String>>>(&self, k: K) -> bool
pub fn contains_key<K: Into<UniCase<String>>>(&self, k: K) -> bool
Returns true if the map contains a value for the specified key. The key may be a String, str or UniCase value.
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut map = CaseInsensitiveHashMap::new();
map.insert("A", 1);
map.insert("B", 2);
map.insert("a", 10);
for (k,v) in &map {
println!("Key = {}, Value = {}", k, v);
}
if map.contains_key("c") {
println!("c is in the map");
} else {
println!("c is NOT in the map");
}
for (k,v) in &mut map {
*v *= 10;
println!("Key = {}, Value = {}", k, v);
}
let keys = map.keys().collect::<Vec<_>>();
println!("keys = {:?}", keys);
let values = map.values().collect::<Vec<_>>();
println!("values = {:?}", values);
}
sourcepub fn drain(&mut self) -> Drain<'_, UniCase<String>, V>
pub fn drain(&mut self) -> Drain<'_, UniCase<String>, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the allocated memory for reuse.
sourcepub fn entry<K: Into<UniCase<String>>>(
&mut self,
k: K,
) -> Entry<'_, UniCase<String>, V>
pub fn entry<K: Into<UniCase<String>>>( &mut self, k: K, ) -> Entry<'_, UniCase<String>, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn get<K: Into<UniCase<String>>>(&self, k: K) -> Option<&V>
pub fn get<K: Into<UniCase<String>>>(&self, k: K) -> Option<&V>
Returns a reference to the value corresponding to the key. The key may be a String, str or UniCase value.
sourcepub fn get_key_value<K: Into<UniCase<String>>>(
&self,
k: K,
) -> Option<(&UniCase<String>, &V)>
pub fn get_key_value<K: Into<UniCase<String>>>( &self, k: K, ) -> Option<(&UniCase<String>, &V)>
Returns the key-value pair corresponding to the supplied key. The key may be a String, str or UniCase value.
sourcepub fn get_mut<K: Into<UniCase<String>>>(&mut self, k: K) -> Option<&mut V>
pub fn get_mut<K: Into<UniCase<String>>>(&mut self, k: K) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key. The key may be a String, str or UniCase value.
sourcepub fn insert<K: Into<UniCase<String>>>(&mut self, k: K, v: V) -> Option<V>
pub fn insert<K: Into<UniCase<String>>>(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map. If the map did not have this key present, None is returned. If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the module-level documentation of HashMap
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut map = CaseInsensitiveHashMap::new();
map.insert("A", 1);
map.insert("B", 2);
map.insert("a", 10);
for (k,v) in &map {
println!("Key = {}, Value = {}", k, v);
}
if map.contains_key("c") {
println!("c is in the map");
} else {
println!("c is NOT in the map");
}
for (k,v) in &mut map {
*v *= 10;
println!("Key = {}, Value = {}", k, v);
}
let keys = map.keys().collect::<Vec<_>>();
println!("keys = {:?}", keys);
let values = map.values().collect::<Vec<_>>();
println!("values = {:?}", values);
}
sourcepub fn iter(&self) -> Iter<'_, UniCase<String>, V>
pub fn iter(&self) -> Iter<'_, UniCase<String>, V>
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (&’a UniCase
sourcepub fn iter_mut(&mut self) -> IterMut<'_, UniCase<String>, V>
pub fn iter_mut(&mut self) -> IterMut<'_, UniCase<String>, V>
An iterator visiting all key-value pairs in arbitrary order,
with mutable references to the values. The iterator element type is
(&’a UniCase
sourcepub fn keys(&self) -> Keys<'_, UniCase<String>, V>
pub fn keys(&self) -> Keys<'_, UniCase<String>, V>
An iterator visiting all keys in arbitrary order. The iterator element type is &’a UniCase
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut map = CaseInsensitiveHashMap::new();
map.insert("A", 1);
map.insert("B", 2);
map.insert("a", 10);
for (k,v) in &map {
println!("Key = {}, Value = {}", k, v);
}
if map.contains_key("c") {
println!("c is in the map");
} else {
println!("c is NOT in the map");
}
for (k,v) in &mut map {
*v *= 10;
println!("Key = {}, Value = {}", k, v);
}
let keys = map.keys().collect::<Vec<_>>();
println!("keys = {:?}", keys);
let values = map.values().collect::<Vec<_>>();
println!("values = {:?}", values);
}
sourcepub fn remove<K: Into<UniCase<String>>>(&mut self, k: K) -> Option<V>
pub fn remove<K: Into<UniCase<String>>>(&mut self, k: K) -> Option<V>
Removes a key from the map, returning the value at the key if the key was previously in the map. The key may be a String, str or UniCase value.
sourcepub fn remove_entry<K: Into<UniCase<String>>>(
&mut self,
k: K,
) -> Option<(UniCase<String>, V)>
pub fn remove_entry<K: Into<UniCase<String>>>( &mut self, k: K, ) -> Option<(UniCase<String>, V)>
Removes a key from the map, returning the stored key and value if the key was previously in the map. The key may be a String, str or UniCase value.
sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate. In other words, remove all pairs (k, v) such that f(&k,&mut v) returns false.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.
sourcepub fn values(&self) -> Values<'_, UniCase<String>, V>
pub fn values(&self) -> Values<'_, UniCase<String>, V>
An iterator visiting all values in arbitrary order. The iterator element type is &’a V.
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
let mut map = CaseInsensitiveHashMap::new();
map.insert("A", 1);
map.insert("B", 2);
map.insert("a", 10);
for (k,v) in &map {
println!("Key = {}, Value = {}", k, v);
}
if map.contains_key("c") {
println!("c is in the map");
} else {
println!("c is NOT in the map");
}
for (k,v) in &mut map {
*v *= 10;
println!("Key = {}, Value = {}", k, v);
}
let keys = map.keys().collect::<Vec<_>>();
println!("keys = {:?}", keys);
let values = map.values().collect::<Vec<_>>();
println!("values = {:?}", values);
}
sourcepub fn values_mut(&mut self) -> ValuesMut<'_, UniCase<String>, V>
pub fn values_mut(&mut self) -> ValuesMut<'_, UniCase<String>, V>
An iterator visiting all values mutably in arbitrary order. The iterator element type is &’a mut V.
Trait Implementations§
source§impl<V: Clone, S> Clone for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Clone,
impl<V: Clone, S> Clone for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Clone,
source§fn clone(&self) -> CaseInsensitiveHashMap<V, S>
fn clone(&self) -> CaseInsensitiveHashMap<V, S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<V: Debug, S> Debug for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Debug,
impl<V: Debug, S> Debug for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Debug,
source§impl<V: Default, S> Default for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Default,
impl<V: Default, S> Default for CaseInsensitiveHashMap<V, S>where
S: BuildHasher + Default,
source§fn default() -> CaseInsensitiveHashMap<V, S>
fn default() -> CaseInsensitiveHashMap<V, S>
source§impl<'a, K, V, S> Extend<(K, &'a V)> for CaseInsensitiveHashMap<V, S>
impl<'a, K, V, S> Extend<(K, &'a V)> for CaseInsensitiveHashMap<V, S>
source§fn extend<T: IntoIterator<Item = (K, &'a V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, &'a V)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<K, V, S> Extend<(K, V)> for CaseInsensitiveHashMap<V, S>
impl<K, V, S> Extend<(K, V)> for CaseInsensitiveHashMap<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)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<K, V> FromIterator<(K, V)> for CaseInsensitiveHashMap<V>
impl<K, V> FromIterator<(K, V)> for CaseInsensitiveHashMap<V>
source§impl<K, V, S> Index<K> for CaseInsensitiveHashMap<V, S>
impl<K, V, S> Index<K> for CaseInsensitiveHashMap<V, S>
source§impl<'a, V, S> IntoIterator for &'a CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
impl<'a, V, S> IntoIterator for &'a CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
source§impl<'a, V, S> IntoIterator for &'a mut CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
impl<'a, V, S> IntoIterator for &'a mut CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
source§impl<V, S> IntoIterator for CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
impl<V, S> IntoIterator for CaseInsensitiveHashMap<V, S>where
S: BuildHasher,
source§impl<V, S> PartialEq for CaseInsensitiveHashMap<V, S>where
V: PartialEq,
S: BuildHasher,
impl<V, S> PartialEq for CaseInsensitiveHashMap<V, S>where
V: PartialEq,
S: BuildHasher,
source§fn eq(&self, other: &CaseInsensitiveHashMap<V, S>) -> bool
fn eq(&self, other: &CaseInsensitiveHashMap<V, S>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<V, S> Eq for CaseInsensitiveHashMap<V, S>where
V: Eq,
S: BuildHasher,
Auto Trait Implementations§
impl<V, S> Freeze for CaseInsensitiveHashMap<V, S>where
S: Freeze,
impl<V, S> RefUnwindSafe for CaseInsensitiveHashMap<V, S>where
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, S> Send for CaseInsensitiveHashMap<V, S>
impl<V, S> Sync for CaseInsensitiveHashMap<V, S>
impl<V, S> Unpin for CaseInsensitiveHashMap<V, S>
impl<V, S> UnwindSafe for CaseInsensitiveHashMap<V, S>where
V: UnwindSafe,
S: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)