Skip to main content

MutableList

Struct MutableList 

Source
pub struct MutableList<A> { /* private fields */ }
Expand description

A mutex-backed double-ended list.

Implementations§

Source§

impl<A> MutableList<A>

Source

pub fn make() -> Self

Empty list.

Source

pub fn append(&self, value: A)

Push value at the back.

Source

pub fn prepend(&self, value: A)

Push value at the front.

Source

pub fn head(&self) -> Option<A>
where A: Clone,

First element, if any.

Source

pub fn tail(&self) -> Chunk<A>
where A: Clone,

All elements after the first (empty when length ≤ 1).

Source

pub fn last(&self) -> Option<A>
where A: Clone,

Last element, if any.

Source

pub fn pop(&self) -> Option<A>

Remove and return the last element.

Source

pub fn shift(&self) -> Option<A>

Remove and return the first element.

Source

pub fn to_chunk(&self) -> Chunk<A>
where A: Clone,

Snapshot of the whole list as an immutable Chunk.

Source

pub fn length(&self) -> usize

Number of elements.

Source

pub fn for_each(&self, f: impl FnMut(&A))

Invokes f for each element in order (holds the mutex for the whole walk).

Auto Trait Implementations§

§

impl<A> !Freeze for MutableList<A>

§

impl<A> RefUnwindSafe for MutableList<A>

§

impl<A> Send for MutableList<A>
where A: Send,

§

impl<A> Sync for MutableList<A>
where A: Send,

§

impl<A> Unpin for MutableList<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for MutableList<A>

§

impl<A> UnwindSafe for MutableList<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.