pub struct SharedVec<T, K: Key = DefaultKey> { /* private fields */ }
Expand description

A SharedVec for storing values of a single type.

Implementations

Constructs an empty SharedVec with a capacity of DEFAULT_CAPACITY.

Constructs an empty SharedVec able to store at least capacity values before needing to allocate.

Pushes a value onto the SharedVec potentially allocating more memory.

Pushes a value produced by func onto the SharedVec potentially allocating more memory.

This method takes a function which is provided with the key where the value will be stored and produces the value to be stored. It allows storing the key of a value inside the value itself.

Panics

May panic if the provided function accesses the SharedVec in any way.

Tries to push a value onto the SharedVec without allocating more memory.

Errors

Fails in case no space is available in the SharedVec.

Same as push_with but without allocating more memory.

See push_with and try_push.

The number of values stored in the SharedVec.

Checks whether the SharedVec is empty.

Returns a shared reference to the value stored for the given key.

The complexity is O(1) if the key has been returned by this SharedVec. It is O(log n) if the key cannot be found or it has been serialized and deserialized without also serializing and deserializing the SharedVec.

Returns an exclusive reference to the value stored for the given key.

For details see get.

Returns a key corresponding to the provided index if a value is stored at the given index.

The complexity is O(log n).

Turns the SharedVec into a Vec.

The index of Key can be used as an index into the returned Vec.

Returns an Iterator over the stored key-value pairs.

Trait Implementations

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

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. Read more

The returned type after indexing.

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

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 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.