[][src]Enum xmachine::Value

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

Methods

impl Value[src]

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

Creates a new reference to a Number

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

Creates a new reference to a String

pub fn list() -> Ref<Self>[src]

Creates a new reference to an empty List

pub fn tree() -> Ref<Self>[src]

Creates a new reference to an empty Tree

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

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

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

Creates a reference to an Error value

pub fn none() -> Ref<Self>[src]

Creates a reference to an None value

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

Copies the contents of this value

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

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

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

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.

pub fn is_err(&self) -> bool[src]

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

Return a reference to a value contained within a collection

Trait Implementations

impl From<Value> for bool[src]

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

impl From<Value> for String[src]

Get a function from the value

impl From<Value> for Vec<Ref<Value>>[src]

Convert Value to unwrapped List

impl From<Value> for BTreeMap<String, Ref<Value>>[src]

Convert Value to unwrapped Tree

impl From<Value> for f64[src]

Convert to floating point value

impl From<Value> for i32[src]

Convert to integer value

impl From<String> for Value[src]

Make Value from String

impl<'_> From<&'_ str> for Value[src]

Make Value from &str

impl From<bool> for Value[src]

Make Value from bool

impl From<f64> for Value[src]

Make Value from Number

impl From<i32> for Value[src]

Make Value from Number

impl From<Vec<Rc<Value>>> for Value[src]

Make Value from List

impl From<BTreeMap<String, Rc<Value>>> for Value[src]

Make Value from Tree

impl PartialEq<Value> for Value[src]

impl PartialOrd<Value> for Value[src]

impl Add<Value> for Value[src]

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

type Output = Value

The resulting type after applying the + operator.

impl Sub<Value> for Value[src]

Subtract two values

type Output = Value

The resulting type after applying the - operator.

impl Mul<Value> for Value[src]

Multiply two values

type Output = Value

The resulting type after applying the * operator.

impl Div<Value> for Value[src]

Divide two values

type Output = Value

The resulting type after applying the / operator.

impl Rem<Value> for Value[src]

Remainder of two values

type Output = Value

The resulting type after applying the % operator.

impl Not for Value[src]

Negate value

type Output = Value

The resulting type after applying the ! operator.

impl Debug for Value[src]

This implementation is a hack for implementing Display for Value

impl Display for Value[src]

How to display value

impl Clone for Value[src]

Auto Trait Implementations

impl Unpin for Value

impl !Send for Value

impl !Sync for Value

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]