pub trait DynamicArray<T>: Array<T> {
    fn with_capacity(capacity: usize) -> Self
    where
        Self: Sized
; fn capacity(&self) -> usize; unsafe fn set_len(&mut self, len: usize); fn reserve(&mut self, additional: usize) { ... } unsafe fn push_unchecked(&mut self, value: T) { ... } fn push(&mut self, value: T) { ... } fn extend<I>(&mut self, iter: I)
    where
        Self: Sized,
        I: IntoIterator<Item = T>
, { ... } fn extend_from_slice(&mut self, other: &[T])
    where
        T: Clone
, { ... } fn extend_with_element(&mut self, value: T, n: usize)
    where
        T: Clone
, { ... } }
Expand description

A simple trait for a dynamic array like struct.

Required Methods

Creates a array with the specified capacity.

The implementation is free to choose if the array can grow beyond this capacity or not.

Returns the capacity of the array.

Change the length of the array.

Provided Methods

Reserve capacity for at least additional more elements.

Panics

If the array cannot satisfy the request.

The default implementation panics if additional > (self.capacity() - self.len()).

Write value to the end of the array and increment the length.

This method is used in the default implementation of push, extend_with_element and extend_from_slice.

Safety

It’s unsafe because the capacity is not checked.

Appends the value to the array.

Panics

If the array is full and cannot grow.

Appends all elements of iter to the array.

Panics

If the array cannot grow to accommodate all elements.

Appends all elements in a slice to the array.

Panics

If the array cannot grow to accommodate all elements.

Extend the array by n additional clones of value.

Panics

If the array cannot grow to accommodate all elements.

Implementors