Struct mocktave::Interpreter
source · pub struct Interpreter { /* private fields */ }
Expand description
Create a persistent interpreter that can call a single container multiple times, resulting in more efficiency code execution.
let mut interp = mocktave::Interpreter::default();
let res1 = interp.eval("a = 5+2");
assert_eq!(res1.get_scalar("a").unwrap(), 7_f64);
let res2 = interp.eval("a = ones(2, 2)");
assert_eq!(res2.get_matrix("a").unwrap(), vec![vec![1.0_f64; 2]; 2]);
let res3 = interp.eval("a = 'asdf'");
assert_eq!(res3.get_string("a").unwrap(), "asdf");
Implementations§
source§impl Interpreter
impl Interpreter
sourcepub fn eval(&self, input: &str) -> InterpreterResults
pub fn eval(&self, input: &str) -> InterpreterResults
This function does the heavy lifting in the interpreter struct.
Trait Implementations§
source§impl Default for Interpreter
impl Default for Interpreter
Auto Trait Implementations§
impl !RefUnwindSafe for Interpreter
impl Send for Interpreter
impl Sync for Interpreter
impl Unpin for Interpreter
impl !UnwindSafe for Interpreter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request