Struct linked_list::List

source ·
pub struct List<G: AdapterWrapped> { /* 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: AdapterWrapped> List<G>

source

pub const fn new() -> Self

Constructs a new empty linked list.

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 unsafe fn insert_after( &mut self, existing: NonNull<G::EntryType>, 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. 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 front(&self) -> Option<&G::EntryType>

Returns the first element of the list, if one exists.

source

pub fn back(&self) -> Option<&G::EntryType>

Returns the last element of the list, if one exists.

source

pub fn cursor_front(&self) -> Cursor<'_, G>

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

Trait Implementations§

source§

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

source§

fn default() -> Self

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

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

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<G> RefUnwindSafe for List<G>

§

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

§

impl<G> Sync for List<G>
where <G as Adapter>::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>,

§

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

§

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.