Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. list
  6. UnsafeList

UnsafeList

Struct UnsafeList 

Source
pub struct UnsafeList<T, A: Adapter<T>> { /* private fields */ }

Implementations§

Source§

impl<T, A: Adapter<T>> UnsafeList<T, A>

Source

pub const fn new() -> Self

Source

pub unsafe fn is_empty(&self) -> bool

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

Source

pub unsafe fn is_element_linked(&self, element: NonNull<T>) -> bool

Returns true if element is in ANY list that uses this list’s adapter.

§Safety

element must be a valid, non-null pointer.

Source

pub unsafe fn push_front_unchecked(&mut self, element: NonNull<T>)

Unchecked means:

  • We don’t assert!((*element_ptr.as_ptr()).is_unlinked());
  • We don’t check that element is non-null.
§Safety

It is up to the caller to ensure exclusive access to the list and its members.

It is up to the caller to ensure the element is not in a list.

Source

pub unsafe fn push_back_unchecked(&mut self, element: NonNull<T>)

Unchecked means:

  • We don’t assert!((*element_ptr.as_ptr()).is_unlinked());
  • We don’t check that element is non-null.
§Safety

It is up to the caller to ensure exclusive access to the list and its members.

It is up to the caller to ensure the element is not in a list.

Unlinks element from the linked list.

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

It is up to the caller to ensure the element is in the list.

§Safety

The caller must ensure that the element points to a valid T.

Source

pub unsafe fn for_each<E, F: FnMut(&T) -> Result<(), E>>( &self, callback: F, ) -> Result<(), E>

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

Source

pub fn iter(&self) -> Iter<'_, T, A> ⓘ

Source

pub unsafe fn filter<F: FnMut(&mut T) -> bool>(&mut self, callback: F)

Filter iterates over every element in the list calling callback on each one. If callback returns false, the element will be removed from the list without modifying the element itself. It is safe to add the element to the another linked list within callback if it returns false.

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

Source

pub unsafe fn peek_head(&self) -> Option<NonNull<T>>

Return a reference to the first element in the list without removing it.

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

Source

pub unsafe fn pop_head(&mut self) -> Option<NonNull<T>>

Return a reference to the first element in the list, clearing the prev/next fields in the element.

§Safety

It is up to the caller to ensure exclusive access to the list and its members.

Source§

impl<T, A: Adapter<T>> UnsafeList<T, A>

Source

pub unsafe fn sorted_insert_by_unchecked<F: FnMut(&T, &T) -> Ordering>( &mut self, element: NonNull<T>, compare: F, )

Unchecked means:

  • We don’t assert!((*element_ptr.as_ptr()).is_unlinked());
  • We don’t check that element is non-null.
§Safety

It is up to the caller to ensure exclusive access to the list and its members.

It is up to the caller to ensure the element is not in a list.

Trait Implementations§

Source§

impl<T, A: Adapter<T>> Default for UnsafeList<T, A>

Source§

fn default() -> Self

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

impl<T, A: Adapter<T>> Send for UnsafeList<T, A>

Source§

impl<T, A: Adapter<T>> Sync for UnsafeList<T, A>

Auto Trait Implementations§

§

impl<T, A> !RefUnwindSafe for UnsafeList<T, A>

§

impl<T, A> !UnwindSafe for UnsafeList<T, A>

§

impl<T, A> Forget for UnsafeList<T, A>

§

impl<T, A> Freeze for UnsafeList<T, A>
where PhantomData<T>: Freeze, PhantomData<A>: Freeze,

§

impl<T, A> Move for UnsafeList<T, A>

§

impl<T, A> Unpin for UnsafeList<T, A>
where PhantomData<T>: Unpin, PhantomData<A>: Unpin,

§

impl<T, A> UnsafeUnpin for UnsafeList<T, A>
where PhantomData<T>: UnsafeUnpin, PhantomData<A>: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

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

Performs the conversion.