pub struct HashVec<K: Eq + Hash, V> { /* private fields */ }

Implementations

Creates a new, empty map.

Creates a new, empty hashvec with the specified capacity.

Creates a hashvec from a vector of key-value pairs.

Internally, this uses HashVec::append_vec(), which means that redundant keys’ entries will be overwritten and moved to the end of the hashvec sequentially.

Returns the number of elements the hashvec can hold without reallocating.

Returns the number of elements in the hashvec.

Returns true if the hashvec contains no elements.

Clears the hashvec, removing all entries.

Keep in mind this will not reallocate memory.

Inserts an entry into the hashvec, or replaces an existing one.

Appends an entry to the back of the hashvec.

If an entry with an identical key was already in the hashvec, it is removed before the new entry is inserted.

Panics

Panics if the new capacity either overflows usize or exceeds isize::MAX bytes.

Removes the last entry from the hashvec and returns it (or None if the hashvec is empty).

Appends all entries of other into Self, leaving other empty.

Panics

Panics if the number of elements in the hashvec either overflows usize or exceeds isize::MAX bytes

Appends a vector of key-value pairs onto the hashvec.

Internally, this uses HashVec::push(), which means that redundant keys’ entries will be overwritten and moved to the end of the hashvec sequentially.

Swaps the location of the provided keys’ entries

If either one of the keys is not already in the hashvec, this is a no-op.

Swaps the location of the entries at the provided indices

If either one of the indices exceeds the current length of the hashvec, this is a no-op.

Returns true if the hashvec contains an entry corresponding to the provided key.

Returns a reference to the value corresponding to the key, if it exists.

Returns a mutable reference to the value corresponding to the key, if it exists.

Changes an entry’s key, preserving and returning a reference to the associated value.

If the hashvec did not have an entry corresponding to the old key, None is returned.

source

pub fn remove_key_entry(&mut self, k: &K) -> Option<(K, V)>

Removes a key from the hashvec, returning the stored key and value if the key was previously in the hashvec.

Returns the index of the provided key, if the key exists.

Removes a key from the hashvec, returning the stored value if the key was previously in the hashvec.

Reserves capacity for at least additional more elements to be inserted in the HashVec. The collection may reserve more space to avoid frequent reallocations.

Panics

Panics if the new capacity either overflows usize or exceeds isize::MAX bytes.

Shrinks the capacity of the hashvec with a lower limit.

The capacity will remain at least as large as both the length and the supplied value.

If the current capacity is less than the lower limit, this is a no-op.

Shrinks the capacity of the hashvec as much as possible, according to internal rules.

Trait Implementations

Formats the value using the given formatter. Read more

The returned type after indexing.

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.