pub enum ManagedMap<'a, K: 'a, V: 'a> {
    Borrowed(&'a mut [Option<(K, V)>]),
    Owned(BTreeMap<K, V>),
}
Expand description

A managed map.

This enum can be used to represent exclusive access to maps. In Rust, exclusive access to an object is obtained by either owning the object, or owning a mutable pointer to the object; hence, “managed”.

The purpose of this enum is providing good ergonomics with std present while making it possible to avoid having a heap at all (which of course means that std is not present). To achieve this, the variants other than Borrow are only available when the corresponding feature is opted in.

Unlike Managed and ManagedSlice, the managed map is implemented using a B-tree map when allocation is available, and a sorted slice of key-value pairs when it is not. Thus, algorithmic complexity of operations on it depends on the kind of map.

A function that requires a managed object should be generic over an Into<ManagedMap<'a, T>> argument; then, it will be possible to pass either a Vec<T>, or a &'a mut [T] without any conversion at the call site.

See also Managed.

Variants

Borrowed(&'a mut [Option<(K, V)>])

Borrowed variant.

Owned(BTreeMap<K, V>)

Owned variant, only available with the std or alloc feature enabled.

Implementations

ManagedMap contains no elements?

Returns the number of elements in the ManagedMap.

Trait Implementations

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

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.