rustdoc-mcp 0.6.5

mcp server for rustdocs
---
source: rustdoc-mcp/src/tests.rs
expression: result_std_collections_hashmap
---
Item: HashMap
Kind: Struct
Visibility: Public
Defined at: std::collections::hash::map::HashMap

A [hash map] implemented with quadratic probing and SIMD lookup.

By default, `HashMap` uses a hashing algorithm selected to provide
resistance against HashDoS attacks. The algorithm is randomly seeded, and a
reasonable best-effort is made to generate this seed from a high quality,
secure source of randomness provided by the host without blocking the
program. Because of this, the randomness of the seed depends on the output
quality of the system's random number generator when the seed is created.
In particular, seeds generated when the system's entropy pool is abnormally
low such as during system boot may be of a lower quality.
[+217 lines elided]


```rust
struct HashMap<K, V, S = crate::hash::RandomState, A: Allocator = crate::alloc::Global> {
}
```


Associated Types:

• pub fn new() -> HashMap<K, V, RandomState>
    Creates an empty `HashMap`. [+10 more lines]

• pub fn with_capacity(capacity: usize) -> HashMap<K, V, RandomState>
    Creates an empty `HashMap` with at least the specified capacity. [+11 more lines]

• pub fn new_in(alloc: A) -> Self
    Creates an empty `HashMap` using the given allocator. [+13 more lines]

• pub fn with_capacity_in(capacity: usize, alloc: A) -> Self
    Creates an empty `HashMap` with at least the specified capacity using [+15 more lines]

• pub const fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
    Creates an empty `HashMap` which will use the given hash builder to hash [+22 more lines]

• pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
    Creates an empty `HashMap` with at least the specified capacity, using [+24 more lines]

• pub fn with_hasher_in(hash_builder: S, alloc: A) -> Self
    Creates an empty `HashMap` which will use the given hash builder and [+23 more lines]

• pub fn with_capacity_and_hasher_in(capacity: usize, hash_builder: S, alloc: A) -> Self
    Creates an empty `HashMap` with at least the specified capacity, using [+25 more lines]

• pub fn capacity(&self) -> usize
    Returns the number of elements the map can hold without reallocating. [+11 more lines]

• pub fn keys(&self) -> Keys<'_, K, V>
    An iterator visiting all keys in arbitrary order. [+22 more lines]

• pub fn into_keys(self) -> IntoKeys<K, V, A>
    Creates a consuming iterator visiting all the keys in arbitrary order. [+25 more lines]

• pub fn values(&self) -> Values<'_, K, V>
    An iterator visiting all values in arbitrary order. [+22 more lines]

• pub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
    An iterator visiting all values mutably in arbitrary order. [+26 more lines]

• pub fn into_values(self) -> IntoValues<K, V, A>
    Creates a consuming iterator visiting all the values in arbitrary order. [+25 more lines]

• pub fn iter(&self) -> Iter<'_, K, V>
    An iterator visiting all key-value pairs in arbitrary order. [+22 more lines]

• pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
    An iterator visiting all key-value pairs in arbitrary order, [+28 more lines]

• pub fn len(&self) -> usize
    Returns the number of elements in the map. [+11 more lines]

• pub fn is_empty(&self) -> bool
    Returns `true` if the map contains no elements. [+11 more lines]

• pub fn drain(&mut self) -> Drain<'_, K, V, A>
    Clears the map, returning all key-value pairs as an iterator. Keeps the [+22 more lines]

• pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F, A>
where
    F: FnMut(&K, &mut V) -> bool
    Creates an iterator which uses a closure to determine if an element (key-value pair) should be removed. [+32 more lines]

• pub fn retain<F>(&mut self, f: F)
where
    F: FnMut(&K, &mut V) -> bool
    Retains only the elements specified by the predicate. [+18 more lines]

• pub fn clear(&mut self)
    Clears the map, removing all key-value pairs. Keeps the allocated memory [+12 more lines]

• pub fn hasher(&self) -> &S
    Returns a reference to the map's [`BuildHasher`]. [+11 more lines]

• pub fn reserve(&mut self, additional: usize)
    Reserves capacity for at least `additional` more elements to be inserted [+16 more lines]

• pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
    Tries to reserve capacity for at least `additional` more elements to be inserted [+19 more lines]

• pub fn shrink_to_fit(&mut self)
    Shrinks the capacity of the map as much as possible. It will drop [+15 more lines]

• pub fn shrink_to(&mut self, min_capacity: usize)
    Shrinks the capacity of the map with a lower limit. It will drop [+19 more lines]

• pub fn entry(&mut self, key: K) -> Entry<'_, K, V, A>
    Gets the given key's corresponding entry in the map for in-place manipulation. [+17 more lines]

• pub fn get<Q>(&self, k: &Q) -> Option<&V>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Returns a reference to the value corresponding to the key. [+15 more lines]

• pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Returns the key-value pair corresponding to the supplied key. This is [+47 more lines]

• pub fn get_disjoint_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&mut V>; N]
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Attempts to get mutable references to `N` values in the map at once. [+67 more lines]

• pub unsafe fn get_disjoint_unchecked_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&mut V>; N]
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Attempts to get mutable references to `N` values in the map at once, without validating that [+52 more lines]

• pub fn contains_key<Q>(&self, k: &Q) -> bool
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Returns `true` if the map contains a value for the specified key. [+15 more lines]

• pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Returns a mutable reference to the value corresponding to the key. [+17 more lines]

• pub fn insert(&mut self, k: K, v: V) -> Option<V>
    Inserts a key-value pair into the map. [+23 more lines]

• pub fn try_insert(&mut self, key: K, value: V) -> Result<&mut V, OccupiedError<'_, K, V, A>>
    Tries to insert a key-value pair into the map, and returns [+22 more lines]

• pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Removes a key from the map, returning the value at the key if the key [+16 more lines]

• pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized
    Removes a key from the map, returning the stored key and value if the [+18 more lines]


std traits: Any, Borrow<T>, BorrowMut<T>, Clone, CloneToUninit, Debug, Default, Eq, Extend<(&'a K, &'a V)>, Extend<(K, V)> [+18 more]