logo
pub struct Deque<T> { /* private fields */ }
Expand description

A double-ended queue (abbreviated to deque), for which elements can be added or remove from both back and front ends.

Underneath the hood, this Deque uses a contiguous memory block as a ring buffer to store values.

References:

Implementations

Constructs a new, empty Deque<T>.

For convenience, the deque initially allocates a region of a single T.

Prepends the given element value to the beginning of the container.

Parameters
  • elem - The element to prepend.
Complexity

Constant.

Appends the given element value to the end of the container.

Parameters
  • elem - The element to append.
Complexity

Constant.

Removes and returns the first element of the container. If there are no elements in the container, return None.

Complexity

Constant.

Removes and returns the last element of the container. If there are no elements in the container, return None.

Complexity

Constant.

Peeks the first element of the container. If there are no elements in the container, return None.

Complexity

Constant.

Peeks the last element of the container. If there are no elements in the container, return None.

Complexity

Constant.

Checks whether the container is empty.

Complexity

Constant.

Gets the number of elements in the container.

Complexity

Constant.

Creates an iterator that yields immutable reference of each element.

Creates an iterator that yields mutable reference of each element.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. 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

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