Enum lovm2::value::Value[][src]

pub enum Value {
    Nil,
    Bool(bool),
    Int(i64),
    Float(f64),
    Str(String),
    Dict(IndexMap<Value, Value, RandomState>),
    List(Vec<Value, Global>),
    Ref(Reference),
    Iter(Rc<RefCell<Iter>>),
    Any(Rc<RefCell<Handle>>),
}

Runtime representation of values

Variants

Nil
Bool(bool)
Int(i64)
Float(f64)
Str(String)
List(Vec<Value, Global>)
Iter(Rc<RefCell<Iter>>)
Any(Rc<RefCell<Handle>>)

Implementations

impl Value[src]

pub fn conv(self, ty: ValueType) -> Result<Value, Lovm2Error>[src]

Try converting the value into given type.

pub fn cast_inplace(&mut self, ty: ValueType) -> Result<(), Lovm2Error>[src]

Try converting the value into given type and update inplace.

pub fn as_bool(&self) -> Result<Value, Lovm2Error>[src]

Try turning a value into Bool.

pub fn as_float(&self) -> Result<Value, Lovm2Error>[src]

Try turning a value into Float.

pub fn as_integer(&self) -> Result<Value, Lovm2Error>[src]

Try turning a value into Int.

pub fn as_integer_round(&self) -> Result<Value, Lovm2Error>[src]

Try turning a value into Int while doing correct float rounding.

pub fn as_str(&self) -> Result<Value, Lovm2Error>[src]

Try turning a value into Str.

pub fn as_any_inner(&self) -> Result<Rc<RefCell<Handle>>, Lovm2Error>[src]

Try getting the contained AnyRef.

pub fn as_bool_inner(&self) -> Result<bool, Lovm2Error>[src]

Try turning a value into a Rust bool.

pub fn as_float_inner(&self) -> Result<f64, Lovm2Error>[src]

Try turning a value into a Rust f64.

pub fn as_integer_inner(&self) -> Result<i64, Lovm2Error>[src]

Try turning a value into a Rust i64.

pub fn as_integer_round_inner(&self) -> Result<i64, Lovm2Error>[src]

Try turning a value into a Rust i64 while doing correct float rounding.

pub fn as_str_inner(&self) -> Result<String, Lovm2Error>[src]

Try turning a value into a Rust String.

pub fn type_id(&self) -> Result<ValueType, Lovm2Error>[src]

Return the ValueType of this value. Used for converting between values.

impl Value[src]

pub fn create_any<T>(from: T) -> Value where
    T: Any
[src]

Create a Handle to the given value.

pub fn clone_inner(&self) -> Result<Value, Lovm2Error>[src]

If the current value is an instance of Ref, this function will return an owned clone of the innermost value. If the value is not a reference, this is just a clone.

pub fn unref_inplace(&mut self) -> Result<(), Lovm2Error>[src]

Ensure that the value is not wrapped in a reference. This is used for stack mutations as first operand.

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

Returns true if the value is a reference.

pub fn iter(&self) -> Result<Iter, Lovm2Error>[src]

Create an iterator from the value. This will return an error if the value does not support iteration.

pub fn deep_clone(&self) -> Value[src]

Returns a completely independent version of the value. This will recursively clone the items of List and Dict as well as Ref.

pub fn delete(&mut self, key: &Value) -> Result<(), Lovm2Error>[src]

Delete an item from a value by key.

pub fn get(&self, key: &Value) -> Result<Value, Lovm2Error>[src]

Retrieve an item by key.

pub fn get_by_index(&self, idx: usize) -> Result<Value, Lovm2Error>[src]

Get an item by a number. This is mainly used for iteration.

pub fn len(&self) -> Result<usize, Lovm2Error>[src]

Retrieve the length of the value.

pub fn set(&mut self, key: &Value, val: Value) -> Result<(), Lovm2Error>[src]

Insert a new item into the value.

impl Value[src]

pub fn dict() -> Value[src]

Create a new instance of Dict.

pub fn list() -> Value[src]

Create a new instance of List.

impl Value[src]

pub fn pow(&self, exp: Value) -> Result<Value, Lovm2Error>[src]

impl Value[src]

pub fn add_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn sub_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn mul_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn div_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn rem_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn shl_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn shr_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn pow_inplace(&mut self, exp: Value) -> Result<(), Lovm2Error>[src]

pub fn and_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn or_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn xor_inplace(&mut self, other: Value) -> Result<(), Lovm2Error>[src]

pub fn not_inplace(&mut self) -> Result<(), Lovm2Error>[src]

Trait Implementations

impl Add<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the + operator.

impl BitAnd<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the & operator.

impl BitOr<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the | operator.

impl BitXor<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the ^ operator.

impl Clone for Value[src]

impl Debug for Value[src]

impl<'de> Deserialize<'de> for Value[src]

impl Display for Value[src]

impl Div<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the / operator.

impl Eq for Value[src]

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

impl From<()> for Value[src]

impl From<Iter> for Value[src]

impl From<String> for Value[src]

impl From<Value> for Reference[src]

impl<T> From<Vec<T, Global>> for Value where
    T: Into<Value>, 
[src]

impl From<bool> for Value[src]

impl From<char> for Value[src]

impl From<f64> for Value[src]

impl From<i64> for Value[src]

impl Hash for Value[src]

impl Into<String> for Value[src]

impl Into<bool> for Value[src]

impl Into<f64> for Value[src]

impl Into<i64> for Value[src]

impl Mul<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the * operator.

impl Not for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the ! operator.

impl Ord for Value[src]

impl PartialEq<Value> for Reference[src]

impl PartialEq<Value> for Value[src]

impl PartialOrd<Value> for Value[src]

impl Rem<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the % operator.

impl Serialize for Value[src]

impl Shl<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the << operator.

impl Shr<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the >> operator.

impl Sub<Value> for Value[src]

type Output = Result<Value, Lovm2Error>

The resulting type after applying the - operator.

impl TryFrom<Value> for Iter[src]

type Error = Lovm2Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[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]

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