Struct List

Source
pub struct List<G: GetLinksWrapped> { /* private fields */ }
Expand description

A linked list.

Elements in the list are wrapped and ownership is transferred to the list while the element is in the list.

Implementations§

Source§

impl<G: GetLinksWrapped> List<G>

Source

pub const fn new() -> Self

Constructs a new empty linked list.

Source

pub fn iter(&self) -> Iterator<'_, G>

Returns an iterator for the list starting at the first entry.

Source

pub const fn is_empty(&self) -> bool

Returns whether the list is empty.

Source

pub fn push_back(&mut self, data: G::Wrapped)

Adds the given object to the end (back) of the list.

It is dropped if it’s already on this (or another) list; this can happen for reference-counted objects, so dropping means decrementing the reference count.

Source

pub fn push_front(&mut self, data: G::Wrapped)

Adds the given object to the first (front) of the list.

It is dropped if it’s already on this (or another) list; this can happen for reference-counted objects, so dropping means decrementing the reference count.

Source

pub unsafe fn insert_after(&mut self, existing: &G::Wrapped, data: G::Wrapped)

Inserts the given object after existing.

It is dropped if it’s already on this (or another) list; this can happen for reference-counted objects, so dropping means decrementing the reference count.

§Safety

Callers must ensure that existing points to a valid entry that is on the list.

Source

pub unsafe fn remove(&mut self, data: &G::Wrapped) -> Option<G::Wrapped>

Removes the given entry.

§Safety

Callers must ensure that data is either on this list or in no list. It being on another list leads to memory unsafety.

Source

pub fn pop_front(&mut self) -> Option<G::Wrapped>

Removes the element currently at the front of the list and returns it.

Returns None if the list is empty.

Source

pub fn cursor_front_mut(&mut self) -> CursorMut<'_, G>

Returns a mutable cursor starting on the first (front) element of the list.

Trait Implementations§

Source§

impl<G: GetLinksWrapped> Default for List<G>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<G: GetLinksWrapped> Drop for List<G>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<G> Freeze for List<G>

§

impl<G> RefUnwindSafe for List<G>

§

impl<G> Send for List<G>
where <G as GetLinks>::EntryType: Send,

§

impl<G> Sync for List<G>
where <G as GetLinks>::EntryType: Sync,

§

impl<G> Unpin for List<G>

§

impl<G> UnwindSafe for List<G>

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.