Enum List

Source
pub enum List<'t, T> {
    Pair(T, &'t List<'t, T>),
    Null,
}
Expand description

Cons list. Only works with normal references. That’s because making it generic for the reference/container type appears unworkable, even though feasible in principle, due to requiring explicit type parameters on every single cons call. The solution will be to generate the code for versions using Rc, Arc or whatever when needed. (Or, use dyn?, or perhaps/probably rather, enum.)

Variants§

§

Pair(T, &'t List<'t, T>)

§

Null

Implementations§

Source§

impl<'t, T> List<'t, T>

Source

pub fn len(&self) -> usize

Source

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

Source

pub fn rest(&self) -> Option<&List<'_, T>>

Source

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

Source

pub fn as_ref_vec(&self) -> Vec<&T>

A Vec of all the values as references.

Source

pub fn to_vec(&self) -> Vec<T>
where T: Clone,

Source§

impl<'t, T: PartialEq> List<'t, T>

Source

pub fn contains(&self, val: &T) -> bool

Report whether a List contains a particular value.

Source§

impl<'t, K: PartialEq, V> List<'t, (K, V)>

Source

pub fn alist_get(&self, key: &K) -> Option<&V>

In a List of (K, V) pairs, get the first V for which the K == key.

Auto Trait Implementations§

§

impl<'t, T> Freeze for List<'t, T>
where T: Freeze,

§

impl<'t, T> RefUnwindSafe for List<'t, T>
where T: RefUnwindSafe,

§

impl<'t, T> Send for List<'t, T>
where T: Send + Sync,

§

impl<'t, T> Sync for List<'t, T>
where T: Sync,

§

impl<'t, T> Unpin for List<'t, T>
where T: Unpin,

§

impl<'t, T> UnwindSafe for List<'t, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.