Enum Value

Source
pub enum Value<C: 'static + Context> {
    AtomicWord(AtomicIsize, C::ValueMeta),
    BuiltinFunction(Symbol, C::BuiltinFunction, C::ValueMeta),
    Byte(u8, C::ValueMeta),
    Bytes(Gc<Vec<u8>>, C::ValueMeta),
    Cons(Gc<Value<C>>, Gc<Value<C>>, C::ValueMeta),
    Fixnum(isize, C::ValueMeta),
    Func(Option<Symbol>, Gc<Args<C>>, C::UserFunction, C::ValueMeta),
    Object(C::ObjectVtable, Vec<Gc<Value<C>>>, C::ValueMeta),
    Nil(C::ValueMeta),
    String(Gc<String>, C::ValueMeta),
    Symbol(Symbol, C::ValueMeta),
    Vector(Vec<Gc<Value<C>>>, C::ValueMeta),
}
Expand description

A single OftLisp value.

Variants§

§

AtomicWord(AtomicIsize, C::ValueMeta)

A mutable, signed, machine-sized integer.

§

BuiltinFunction(Symbol, C::BuiltinFunction, C::ValueMeta)

A built-in function.

§

Byte(u8, C::ValueMeta)

An unsigned 8-bit integer.

§

Bytes(Gc<Vec<u8>>, C::ValueMeta)

A vector of arbitrary bytes, not subject to the UTF-8 condition of Strings.

§

Cons(Gc<Value<C>>, Gc<Value<C>>, C::ValueMeta)

A cons cell, used to create lists, trees, and other data structures.

§

Fixnum(isize, C::ValueMeta)

A signed machine-sized integer.

§

Func(Option<Symbol>, Gc<Args<C>>, C::UserFunction, C::ValueMeta)

A user-defined function.

§

Object(C::ObjectVtable, Vec<Gc<Value<C>>>, C::ValueMeta)

The object type, containing a vtable and values.

§

Nil(C::ValueMeta)

The nil literal, used to terminate lists and signal failure (or the lack of interesting results).

§

String(Gc<String>, C::ValueMeta)

A UTF-8 string.

§

Symbol(Symbol, C::ValueMeta)

An interned symbol, which may be compared in O(1).

§

Vector(Vec<Gc<Value<C>>>, C::ValueMeta)

A fixed-length collection with O(1) lookup.

Implementations§

Source§

impl<C: 'static + Context> Value<C>

Source

pub fn bool(b: bool) -> Gc<Value<C>>

A pseudo-constructor that converts a bool to a Value.

Source

pub fn improper_list<II: IntoIterator<Item = Gc<Value<C>>>>( iter: II, last: Gc<Value<C>>, meta: C::ValueMeta, ) -> Gc<Value<C>>

Converts an Iterator and a last element to an improper cons-list.

Source

pub fn list<II: IntoIterator<Item = Gc<Value<C>>>>( iter: II, meta: C::ValueMeta, ) -> Gc<Value<C>>

Converts an Iterator to a cons-list.

Source

pub fn meta(&self) -> C::ValueMeta

Extracts the metadata from a Value.

Source

pub fn ordering(o: Option<CmpOrdering>) -> Gc<Value<C>>

Converts an ordering to a Value.

Source

pub fn transmute_with<C2, F>(&self, f: &F) -> Option<Value<C2>>
where C2: 'static + Context, F: Fn(&C::ValueMeta) -> Option<C2::ValueMeta>,

Converts a Value between Contexts.

Will fail to transmute functions and objects.

Source

pub fn transmute_data<C2: 'static + Context>(&self) -> Option<Value<C2>>

Converts a Value between Contexts.

Will fail to transmute functions and objects. Any metadata will be discarded, with the default for the destination being used. To preserve metadata, use transmute_with instead.

Source

pub fn vector<II: IntoIterator<Item = Gc<Value<C>>>>(iter: II) -> Gc<Value<C>>

Converts an Iterator to a vector.

Trait Implementations§

Source§

impl<C: 'static + Context> Clone for Value<C>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: 'static + Context> Debug for Value<C>

Source§

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

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

impl<C: 'static + Context> Display for Value<C>

Source§

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

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

impl<C: 'static + Context> Drop for Value<C>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<C: 'static + Context> Finalize for Value<C>

Source§

impl<C: 'static + Context> PartialEq for Value<C>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C: 'static + Context> PartialOrd for Value<C>

Source§

fn partial_cmp(&self, other: &Self) -> Option<CmpOrdering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<C: 'static + Context> Trace for Value<C>

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects

Auto Trait Implementations§

§

impl<C> !Freeze for Value<C>

§

impl<C> !RefUnwindSafe for Value<C>

§

impl<C> !Send for Value<C>

§

impl<C> !Sync for Value<C>

§

impl<C> Unpin for Value<C>

§

impl<C> !UnwindSafe for Value<C>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.