LList

Struct LList 

Source
pub struct LList<T: Clone> { /* private fields */ }
Expand description

This LList structure provides a simple interface for creating and manipulating cons cells in a linked lst fashion. It utilizes a bump allocator to allocate memory for cons cells avoiding the overhead of system memory allocation.

Implementations§

Source§

impl<T: Clone> LList<T>

Source

pub fn new() -> LList<T>

Creates a new typed allocator

Source

pub fn cons<'a>(&self, content: T, cons_ref: &ConsRef<'a, T>) -> ConsRef<'a, T>

Creates a new cons cell with the provided content and cdr reference.

This function allocates memory for a new cons cell using the internal bump allocator. It sets the car of the cons cell to the provided content and the cdr.

Arguments:

  • content: The data to be stored in the car of the new cons cell.
  • cons_ref: A reference to the cons cell that should be linked as the cdr.

Returns: A ConsRef representing the reference of newly created cons cell.

Source

pub fn cons_ptr<'a>( &self, content_ptr: *mut T, cons_ref: &ConsRef<'a, T>, ) -> ConsRef<'a, T>

Creates a new cons cell with a pointer to content and cdr reference.

Source

pub fn nil(&self) -> ConsRef<'_, T>

Creates a ConsRef representing an empty list (nil).

This function returns a ConsRef with a null pointer indicating the end of the list.

Returns: A ConsRef representing an empty list

Source

pub fn rplaca<'a>( &self, cons_ref: &mut ConsRef<'a, T>, content_ptr: *mut T, ) -> ConsRef<'a, T>

rplaca replaces the cdr of cons_ref with content_ptr

Source

pub fn rplacd<'a>( &self, cons_ref: &mut ConsRef<'a, T>, another: ConsRef<'a, T>, ) -> ConsRef<'a, T>

rplacd replaces the cdr of cons_ref with another

Trait Implementations§

Source§

impl<T: Debug + Clone> Debug for LList<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + Clone> Default for LList<T>

Source§

fn default() -> LList<T>

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

impl<T: Clone> Drop for LList<T>

Implement drop contents

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for LList<T>

§

impl<T> !RefUnwindSafe for LList<T>

§

impl<T> !Send for LList<T>

§

impl<T> !Sync for LList<T>

§

impl<T> Unpin for LList<T>
where T: Unpin,

§

impl<T> !UnwindSafe for LList<T>

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.