xmachine

Enum Value

Source
pub enum Value {
    String(String),
    Number(f64),
    List(Vec<Ref<Self>>),
    Tree(BTreeMap<String, Ref<Self>>),
    Function(Function<Machine, (), Machine>),
    Error(String),
    None,
}

Variants§

§

String(String)

§

Number(f64)

§

List(Vec<Ref<Self>>)

§

Tree(BTreeMap<String, Ref<Self>>)

§

Function(Function<Machine, (), Machine>)

§

Error(String)

§

None

Implementations§

Source§

impl Value

Source

pub fn number<N: Into<f64>>(n: N) -> Ref<Self>

Creates a new reference to a Number

Source

pub fn string<S: ToString>(s: S) -> Ref<Self>

Creates a new reference to a String

Source

pub fn list() -> Ref<Self>

Creates a new reference to an empty List

Source

pub fn tree() -> Ref<Self>

Creates a new reference to an empty Tree

Source

pub fn function( f: impl 'static + Fn(&mut Machine), context: &Machine, ) -> Ref<Self>

Creates a reference to a Function with a captured context, basically a Closure

Source

pub fn error<S: ToString>(s: S) -> Ref<Self>

Creates a reference to an Error value

Source

pub fn none() -> Ref<Self>

Creates a reference to an None value

Source

pub fn copy(&self) -> Ref<Self>

Copies the contents of this value

Source

pub fn call(&self, machine: &mut Machine)

Call this function in the context of the Machine captured when this instance of the function was created

Source

pub fn call_global(&self, machine: &mut Machine)

Call this function in the context of the current machine, meaning, execute the instructions of this function as if they were not in a function.

Source

pub fn is_err(&self) -> bool

Source

pub fn index<S: ToString>(&mut self, s: S) -> Ref<Self>

Return a reference to a value contained within a collection

Trait Implementations§

Source§

impl Add for Value

############################################################## The following traits are for implementing operators and logic! ############################################################## Add two values

Source§

type Output = Value

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Debug for Value

This implementation is a hack for implementing Display for Value

Source§

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

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

impl Display for Value

How to display value

Source§

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

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

impl Div for Value

Divide two values

Source§

type Output = Value

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl From<&str> for Value

Make Value from &str

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<String, Rc<Value>>> for Value

Make Value from Tree

Source§

fn from(t: BTreeMap<String, Ref<Value>>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Make Value from String

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for BTreeMap<String, Ref<Value>>

Convert Value to unwrapped Tree

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for String

Get a function from the value

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for Vec<Ref<Value>>

Convert Value to unwrapped List

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for bool

############################################################ The following traits are for implementing foreign functions! ############################################################ Convert Value into a bool

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for f64

Convert to floating point value

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for i32

Convert to integer value

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Rc<Value>>> for Value

Make Value from List

Source§

fn from(l: Vec<Ref<Value>>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Make Value from bool

Source§

fn from(n: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Make Value from Number

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Make Value from Number

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for Value

Convert Value into Iter

Source§

type Item = Rc<Value>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Value as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Mul for Value

Multiply two values

Source§

type Output = Value

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Not for Value

Negate value

Source§

type Output = Value

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> 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 PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

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 Rem for Value

Remainder of two values

Source§

type Output = Value

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl Sub for Value

Subtract two values

Source§

type Output = Value

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

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, dst: *mut T)

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

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