Trait extendr_api::robj::Eval

source ·
pub trait Eval: GetSexp {
    // Provided methods
    fn eval(&self) -> Result<Robj> { ... }
    fn eval_with_env(&self, env: &Environment) -> Result<Robj> { ... }
    fn eval_blind(&self) -> Robj { ... }
}

Provided Methods§

source

fn eval(&self) -> Result<Robj>

Evaluate the expression in R and return an error or an R object.

use extendr_api::prelude::*;
test! {

   let add = lang!("+", 1, 2);
   assert_eq!(add.eval().unwrap(), r!(3));
}
source

fn eval_with_env(&self, env: &Environment) -> Result<Robj>

Evaluate the expression in R and return an error or an R object.

use extendr_api::prelude::*;
test! {

   let add = lang!("+", 1, 2);
   assert_eq!(add.eval_with_env(&global_env()).unwrap(), r!(3));
}
source

fn eval_blind(&self) -> Robj

Evaluate the expression and return NULL or an R object.

use extendr_api::prelude::*;
test! {
   let bad = lang!("imnotavalidfunctioninR", 1, 2);
   assert_eq!(bad.eval_blind(), r!(NULL));
}

Implementors§