#[repr(C)]
pub struct Deque<T> { /* private fields */ }
Expand description

An arena-allocated deque.

Under the covers, this is implemented as a List. Because these lists are singly-linked, we can only add elements to, and remove them from, one side of the list.

To handle this, each deque stores its contents either forwards or backwards. We automatically shift between these two representations as needed, depending on the requirements of each method.

Note that we cache the result of reversing the list, so it should be quick to switch back and forth between representations as long as you have not added any additional elements to the deque! If performance is critical, you should ensure that you don’t call methods in a pattern that causes the deque to reverse itself each time you add an element.

Implementations

Creates a new DequeArena that will manage deques of this type.

Returns whether this deque is empty.

Returns an empty deque.

Returns whether we have already calculated the reversal of this deque.

Returns an iterator over the contents of this deque, with no guarantee about the ordering of the elements. (By not caring about the ordering of the elements, you can call this method regardless of which direction the deque’s elements are currently stored. And that, in turn, means that we only need shared access to the arena, and not mutable access to it.)

Ensures that this deque has computed its backwards-facing list of elements.

Ensures that this deque has computed its forwards-facing list of elements.

Pushes a new element onto the front of this deque.

Pushes a new element onto the back of this deque.

Removes and returns the element from the front of this deque. If the deque is empty, returns None.

Removes and returns the element from the back of this deque. If the deque is empty, returns None.

Returns an iterator over the contents of this deque in a forwards direction.

Returns an iterator over the contents of this deque in a backwards direction.

Returns an iterator over the contents of this deque in a forwards direction, assuming that we have already computed its forwards-facing list of elements via ensure_forwards. Panics if we haven’t already computed it.

Returns an iterator over the contents of this deque in a backwards direction, assuming that we have already computed its backwards-facing list of elements via ensure_backwards. Panics if we haven’t already computed it.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The type that is used to store values of Self inside of a ControlledOption. This might be Self itself, if your niche is a valid instance of the type, but which violates some runtime constraint. But if you cannot easily create your niche as an instance of Self, you can use some other type, you can use some other type instead. Read more

Returns the niche value for this type that should be used to represent None for a ControlledOption. Read more

Returns whether value is the niche value for this type.

Transforms a non-niche value of this type into its Output type. When Output is Self, this will be the identity function. Read more

Transforms a non-niche value of this type from its Output type. When Output is Self, this will be the identity function. 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

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. 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.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Attempts to convert self into T using TryInto<T>. 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.