pub struct CaseInsensitiveHashMap<V, S = RandomState>
where S: BuildHasher,
{ /* private fields */ }

Implementations§

source§

impl<V> CaseInsensitiveHashMap<V, RandomState>

source

pub fn new() -> Self

Creates a new CaseInsensitiveHashMap with the default hasher and capacity.

Examples found in repository?
examples/ex1.rs (line 4)
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);

}
source

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,

source

pub fn with_hasher(hash_builder: S) -> Self

Creates a new CaseInsensitiveHashMap with the specified hasher and default capacity.

source

pub fn with_capacity_and_hasher( capacity: usize, hash_builder: S, ) -> CaseInsensitiveHashMap<V, S>

Creates a new CaseInsensitiveHashMap with the specified capacity and hasher.

source

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.

source

pub fn clear(&mut self)

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

source

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?
examples/ex1.rs (line 13)
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);

}
source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn hasher(&self) -> &S

Returns a reference to the map’s BuildHasher.

source

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?
examples/ex1.rs (line 5)
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);

}
source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

source

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, &’a V).

source

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, &’a mut V).

source

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?
examples/ex1.rs (line 24)
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);

}
source

pub fn len(&self) -> usize

Returns the number of elements in the map.

source

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.

source

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.

source

pub fn reserve(&mut self, additional: usize)

in the HashMap. The collection may reserve more space to avoid frequent reallocations.

§Panics

Panics if the new allocation size overflows usize.

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&UniCase<String>, &mut V) -> bool,

Retains only the elements specified by the predicate. In other words, remove all pairs (k, v) such that f(&k,&mut v) returns false.

source

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.

source

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?
examples/ex1.rs (line 27)
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);

}
source

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,

source§

fn clone(&self) -> CaseInsensitiveHashMap<V, S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug, S> Debug for CaseInsensitiveHashMap<V, S>
where S: BuildHasher + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V: Default, S> Default for CaseInsensitiveHashMap<V, S>
where S: BuildHasher + Default,

source§

fn default() -> CaseInsensitiveHashMap<V, S>

Returns the “default value” for a type. Read more
source§

impl<'a, K, V, S> Extend<(K, &'a V)> for CaseInsensitiveHashMap<V, S>
where K: Into<UniCase<String>>, S: BuildHasher, V: Copy,

source§

fn extend<T: IntoIterator<Item = (K, &'a V)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

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)

🔬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 CaseInsensitiveHashMap<V, S>
where K: Into<UniCase<String>>, S: BuildHasher,

source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

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> FromIterator<(K, V)> for CaseInsensitiveHashMap<V>
where K: Into<UniCase<String>>,

source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<K, V, S> Index<K> for CaseInsensitiveHashMap<V, S>
where K: Into<UniCase<String>>, S: BuildHasher,

§

type Output = V

The returned type after indexing.
source§

fn index(&self, index: K) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, V, S> IntoIterator for &'a CaseInsensitiveHashMap<V, S>
where S: BuildHasher,

§

type Item = (&'a UniCase<String>, &'a V)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, UniCase<String>, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, V, S> IntoIterator for &'a mut CaseInsensitiveHashMap<V, S>
where S: BuildHasher,

§

type Item = (&'a UniCase<String>, &'a mut V)

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, UniCase<String>, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<V, S> IntoIterator for CaseInsensitiveHashMap<V, S>
where S: BuildHasher,

§

type Item = (UniCase<String>, V)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<UniCase<String>, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<V, S> PartialEq for CaseInsensitiveHashMap<V, S>
where V: PartialEq, S: BuildHasher,

source§

fn eq(&self, other: &CaseInsensitiveHashMap<V, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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>

§

impl<V, S> Send for CaseInsensitiveHashMap<V, S>
where S: Send, V: Send,

§

impl<V, S> Sync for CaseInsensitiveHashMap<V, S>
where S: Sync, V: Sync,

§

impl<V, S> Unpin for CaseInsensitiveHashMap<V, S>
where S: Unpin, V: Unpin,

§

impl<V, S> UnwindSafe for CaseInsensitiveHashMap<V, S>
where V: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.