[][src]Enum shroom::primitive::Primitive

pub enum Primitive {
    Int(i64),
    Float(f64),
    Bool(bool),
    Str(String),
}

Emulates a simple dynamic type system for expression evaluation. Contains a single value of type i64, f64, bool or String.

Examples

let x = Primitive::Int(2);
let y = Primitive::Int(3);

assert_eq!(x.add(&y).unwrap().unwrap_int(), 5);

Variants

Int(i64)Float(f64)Bool(bool)Str(String)

Methods

impl Primitive[src]

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

pub fn unwrap_int(&self) -> i64[src]

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

pub fn unwrap_float(&self) -> f64[src]

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

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

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

pub fn unwrap_string(&self) -> &str[src]

pub fn definition(&self) -> String[src]

Returns a string representation of the value in the form of "type(value)"

pub fn parse_int(s: &str) -> Primitive[src]

Defaults to 0 on wrong input

pub fn parse_hex(s: &str) -> Primitive[src]

Defaults to 0 on wrong input

pub fn parse_oct(s: &str) -> Primitive[src]

Defaults to 0 on wrong input

pub fn parse_bin(s: &str) -> Primitive[src]

Defaults to 0 on wrong input

pub fn parse_bool(s: &str) -> Primitive[src]

Defaults to false on wrong input

pub fn parse_float(s: &str) -> Primitive[src]

Defaults to 0.0 on wrong input

pub fn parse_string(s: &str) -> Primitive[src]

Defaults to the empty string ("") on wrong input

pub fn add(&self, other: &Primitive) -> OpResult[src]

pub fn sub(&self, other: &Primitive) -> OpResult[src]

pub fn mul(&self, other: &Primitive) -> OpResult[src]

pub fn div(&self, other: &Primitive) -> OpResult[src]

pub fn modulo(&self, other: &Primitive) -> OpResult[src]

pub fn pow(&self, other: &Primitive) -> OpResult[src]

pub fn shl(&self, other: &Primitive) -> OpResult[src]

pub fn shr(&self, other: &Primitive) -> OpResult[src]

pub fn bitand(&self, other: &Primitive) -> OpResult[src]

pub fn bitor(&self, other: &Primitive) -> OpResult[src]

pub fn bitxor(&self, other: &Primitive) -> OpResult[src]

pub fn greater(&self, other: &Primitive) -> OpResult[src]

pub fn greater_equals(&self, other: &Primitive) -> OpResult[src]

pub fn less(&self, other: &Primitive) -> OpResult[src]

pub fn less_equals(&self, other: &Primitive) -> OpResult[src]

pub fn equals(&self, other: &Primitive) -> OpResult[src]

pub fn not_equals(&self, other: &Primitive) -> OpResult[src]

pub fn and(&self, other: &Primitive) -> OpResult[src]

pub fn or(&self, other: &Primitive) -> OpResult[src]

pub fn not(&self) -> OpResult[src]

pub fn inverse(&self) -> OpResult[src]

Trait Implementations

impl Clone for Primitive[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for Primitive[src]

impl Debug for Primitive[src]

Auto Trait Implementations

impl Send for Primitive

impl Sync for Primitive

Blanket Implementations

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

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

type Owned = T

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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> Any for T where
    T: 'static + ?Sized
[src]