Struct dync::VecDyn

source · []
pub struct VecDyn<V> where
    V: ?Sized + HasDrop
{ /* private fields */ }

Implementations

Construct an empty vector with a specific pointed-to element type.

Construct an empty vector with a capacity for a given number of typed pointed-to elements.

Construct a VecDyn from a given Vec reusing the space already allocated by the given vector.

Construct a vector with the same type as the given vector without copying its data.

Construct a VecDyn from raw bytes and type metadata.

Safety

Almost exclusively the only inputs that are safe here are the ones returned by VecDyn::into_raw_parts.

This function should not be used other than in internal APIs. It exists to enable the into_dyn macro until CoerceUsize is stabilized.

Convert this collection into its raw components.

This function exists mainly to enable the into_dyn macro until CoerceUnsized is stabilized.

Retrieve the associated virtual function table.

Upcast the VecDyn into a more general base VecDyn.

This function converts the underlying virtual function table into a subset of the existing

Clear the data buffer without destroying its type information.

Add an element to this buffer.

If the type of the given element coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

Check if the current buffer contains elements of the specified type. Returns Some(self) if the type matches and None otherwise.

Check if the current buffer contains elements of the specified type. Returns None if the check fails, otherwise a reference to self is returned.

Check if the current buffer contains elements of the specified type. Same as check_ref but consumes and produces a mut reference to self.

Get the TypeId of data stored within this buffer.

Get the number of elements stored in this buffer.

Check if there are any elements stored in this buffer.

Get the size of the element type in bytes.

Return an iterator to a slice representing typed data.

Returns None if the given type T doesn’t match the internal.

Return an iterator to a mutable slice representing typed data.

Returns None if the given type T doesn’t match the internal.

An alternative to using the Into trait.

This function helps the compiler determine the type T automatically.

Convert this buffer into a typed slice. Returs None if the given type T doesn’t match the internal.

Convert this buffer into a typed mutable slice. Returs None if the given type T doesn’t match the internal.

Get a const reference to the i’th element of the buffer.

Get a mutable reference to the i’th element of the buffer.

Move bytes to this buffer.

The given buffer must have the same underlying type as self.

Rotates the slice in-place such that the first mid elements of the slice move to the end while the last self.len() - mid elements move to the front.

After calling rotate_left, the element previously at index mid will become the first element in the slice.

Rotates the slice in-place such that the first self.len() - k elements of the slice move to the end while the last k elements move to the front.

After calling rotate_right, the element previously at index k will become the first element in the slice.

Push a value onto this buffer.

If the type of the given value coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

Note that the vtables need not patch, only the underlying types are required to match.

Push a clone of the referenced value to this buffer.

If the type of the given value coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

This is more efficient than push since it avoids an extra allocation, however it requires the contained value to be Clone.

Get a reference to a value stored in this container at index i.

Return an iterator over untyped value references stored in this buffer.

In contrast to iter, this function defers downcasting on a per element basis. As a result, this type of iteration is typically less efficient if a typed value is needed for each element.

Get a mutable reference to a value stored in this container at index i.

Return an iterator over mutable untyped value references stored in this buffer.

In contrast to iter_mut, this function defers downcasting on a per element basis. As a result, this type of iteration is typically less efficient if a typed value is needed for each element.

Get a const reference to the i’th element of the vector.

This can be used to reinterpret the internal data as a different type. Note that if the size of the given type T doesn’t match the size of the internal type, i will really index the ith T sized chunk in the current vector. See the implementation for details.

Safety

It is assumed that that the vector contains elements of type T and that i is strictly less than the length of this vector, otherwise this function may cause undefined behavior.

This function is a complete opt-out of all safety checks.

Get a mutable reference to the i’th element of the vector.

This can be used to reinterpret the internal data as a different type. Note that if the size of the given type T doesn’t match the size of the internal type, i will really index the ith T sized chunk in the current vector. See the implementation for details.

Safety

It is assumed that that the vector contains elements of type T and that i is strictly less than the length of this vector, otherwise this function may cause undefined behavior.

This function is opts-out of all safety checks.

Construct a typed VecDyn with a given size and filled with the specified default value.

Construct a buffer from a given slice by cloning the data.

Resizes the buffer in-place to store new_len elements and returns an optional mutable reference to Self.

If value does not correspond to the underlying element type, then None is returned and the buffer is left unchanged.

This function has the similar properties to Vec::resize.

Fill the current buffer with clones of the given value.

The size of the buffer is left unchanged. If the given type doesn’t match the internal type, None is returned, otherwise a mutable reference to the modified buffer is returned.

Append cloned items from this buffer to a given Vec.

Return the mutable reference Some(vec) if type matched the internal type and None otherwise.

Clones contents of self into the given Vec.

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

Executes the destructor for this type. Read more

Convert a slice to a VecDyn.

Converts to this type from the input type.

Converts to this type from the input type.

Convert a Vec to a buffer.

Converts to this type from the input type.

Convert a buffer to a Vec with an option to fail.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

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

This method tests for !=.

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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. 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.