[][src]Enum rsc::parser::Expr

pub enum Expr {
    BinOp(OperatorBox<Expr>, Box<Expr>),
    Pow(Box<Expr>, Box<Expr>),
    Neg(Box<Expr>),
    Function(FunctionBox<Expr>),
    Assignment(StringBox<Expr>),
    Constant(f64),
    Identifier(String),
}

Variants

BinOp(OperatorBox<Expr>, Box<Expr>)Pow(Box<Expr>, Box<Expr>)Neg(Box<Expr>)Function(FunctionBox<Expr>)Assignment(StringBox<Expr>)Constant(f64)Identifier(String)

Methods

impl Expr[src]

pub fn replace(&mut self, old: &Expr, new: &Expr, ignore_fields: bool) -> bool[src]

Replaces all instances of old with new. This method returns true if a value has been replaced, and false otherwise.

Example

One could use this function to replace all references to an identifier "x" with the constant 20.

let input = "x^2 * 4";
let replacement = parser::Expr::Constant(20.);
let mut ast = parser::parse(&lexer::tokenize(&input).unwrap()).unwrap();
ast.replace(&parser::Expr::Identifier(String::from("x")), &replacement, false);
assert_eq!(computer::compute(&ast), 1600.);

Trait Implementations

impl PartialEq<Expr> for Expr[src]

impl Clone for Expr[src]

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

Performs copy-assignment from source. Read more

impl Debug for Expr[src]

Auto Trait Implementations

impl Send for Expr

impl Sync for Expr

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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> 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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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