List

Struct List 

Source
pub struct List<Tag, T: Copy> {
    head: Option<T>,
    tail: Option<T>,
    len: usize,
    _tag: PhantomData<Tag>,
}

Fields§

§head: Option<T>§tail: Option<T>§len: usize§_tag: PhantomData<Tag>

Implementations§

Source§

impl<Tag, T: Copy + PartialEq> List<Tag, T>

Source

pub const fn new() -> Self

Source

pub fn head(&self) -> Option<T>

Source

pub fn tail(&self) -> Option<T>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn push_front<S: Get<T> + GetMut<T>>( &mut self, id: T, storage: &mut S, ) -> Result<(), Error>
where <S as Get<T>>::Output: Linkable<Tag, T>,

Source

pub fn push_back<S: Get<T> + GetMut<T>>( &mut self, id: T, storage: &mut S, ) -> Result<(), Error>
where <S as Get<T>>::Output: Linkable<Tag, T>,

Pushes id to the back of the list. If id is already in the list, it is moved to the back.

Errors if id does not exist in storage or if the node corresponding to id is linked but not in the list.

Source

pub fn pop_front<S: Get<T> + GetMut<T>>( &mut self, storage: &mut S, ) -> Result<Option<T>, Error>
where <S as Get<T>>::Output: Linkable<Tag, T>,

Source

pub fn pop_back<S: Get<T> + GetMut<T>>( &mut self, storage: &mut S, ) -> Result<Option<T>, Error>
where <S as Get<T>>::Output: Linkable<Tag, T>,

Source

pub fn remove<S: Get<T> + GetMut<T>>( &mut self, id: T, storage: &mut S, ) -> Result<(), Error>
where <S as Get<T>>::Output: Linkable<Tag, T>,

Removes id from the list. Errors if id does not exist in storage or if the node corresponding to id is not linked.

Detaches id from any list it is currently in. If id is not in any list but is linked, the links are cleared.

Auto Trait Implementations§

§

impl<Tag, T> Freeze for List<Tag, T>
where T: Freeze,

§

impl<Tag, T> RefUnwindSafe for List<Tag, T>

§

impl<Tag, T> Send for List<Tag, T>
where T: Send, Tag: Send,

§

impl<Tag, T> Sync for List<Tag, T>
where T: Sync, Tag: Sync,

§

impl<Tag, T> Unpin for List<Tag, T>
where T: Unpin, Tag: Unpin,

§

impl<Tag, T> UnwindSafe for List<Tag, T>
where T: UnwindSafe, Tag: UnwindSafe,

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, 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.
Source§

impl<T> ThreadArgument for T
where T: Send + 'static,