[−][src]Enum rsc::parser::Expr
Variants
BinOp(Operator, Box<Expr>, Box<Expr>)
Pow(Box<Expr>, Box<Expr>)
Neg(Box<Expr>)
Function(Function, Box<Expr>)
Assignment(String, Box<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(&self) -> 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
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,