pub struct ArrayMap<K, V, const N: usize> { /* private fields */ }
Expand description

A Map backed by an array. The keys must be known statically.

This map is O(1) for all operations. All members must be initialized at creation time so there is no option to insert or remove items from the map. Because of this it can be indexed into using the key type.

Implementations

Function that can be used in const contexts to get a new ArrayMap.

Callers should ensure that each V in the array matches the return of index() from K to get back expected results.

Returns a new ArrayMap where all the values are initialized to the same value

Returns a new ArrayMap where all the values are initialized to the value returned from each call of the closure.

Panics

Panics if K::iter() returns anything other than N items or if K::index() returns a value >= N

Returns a new ArrayMap where all the values are initialized to the same value

Errors

Returns an error the first time that the provided closure returns an error.

Panics

Panics if K::iter() returns anything other than N items or if K::index() returns a value >= N

Collects an iterator of (K, Result<V, E>) into a Result<Self, E>

The trait FromIterator cannot be implemented for Result like it is on a Vec because of the orphan rules.

Errors

Returns an error with the first emitted error from the provided iterator

Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Collects an iterator of (K, Option<V>) into an Option<Self>

Returns None if any of the values is None or if the iterator isn’t long enough.

Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Collects an iterator of (K, V) into an Option<Self>

Returns None if there aren’t enough elements, or not all values of K have been seen.

Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Returns an iterator over all the items in the map. Note that the keys are owned.

Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Returns a mutable iterator over all the items in the map

Panics

Panics if any of the safety requirements in the Indexable trait are wrong

Returns an iterator over all the keys in the map. Note that the keys are owned.

Turns this into an array of mutable references to the original. Useful for calling map when all you need are mutable references

Panics

Can only panic if K::iter() is unstable or doesn’t meet requirements

Turns this into an array of references to the original. Useful for calling map when all you need are references

Panics

Can only panic if K::iter() is unstable or doesn’t meet requirements

Maps all values in this map using the provided function

Panics

Can only panic if K::iter() is unstable or doesn’t meet requirements

Returns an iterator over all the values in the map

Returns a mutable iterator over all the values in the map

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

Creates a value from an iterator. Read more

The returned type after indexing.

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

The returned type after indexing.

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

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

Performs the mutable 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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. 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 resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

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.