pub struct Engine<T> { /* private fields */ }Expand description
Global context for how to evaluate an expression
Mostly this holds all of the functions that can be called during evaluation.
This can typically be created once and used any time an expression evaluation needs to happen.
Implementations§
Source§impl<T> Engine<T>
impl<T> Engine<T>
Sourcepub fn set_function(
&mut self,
name: impl ToString,
function: Box<dyn Function<T>>,
)
pub fn set_function( &mut self, name: impl ToString, function: Box<dyn Function<T>>, )
Add or override a function with the given name
use rets_expression::{Engine, function::{ListFunction, SetFunction}};
let mut engine = Engine::empty();
engine.set_function("LIST", Box::new(ListFunction));
engine.set_function("SET", Box::new(SetFunction));Sourcepub fn with_function(
self,
name: impl ToString,
function: Box<dyn Function<T>>,
) -> Self
pub fn with_function( self, name: impl ToString, function: Box<dyn Function<T>>, ) -> Self
Add or override a function with the given name
use rets_expression::{Engine, function::{ListFunction, SetFunction}};
let engine = Engine::empty()
.with_function("LIST", Box::new(ListFunction))
.with_function("SET", Box::new(SetFunction));Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Engine<T>
impl<T> !RefUnwindSafe for Engine<T>
impl<T> !Send for Engine<T>
impl<T> !Sync for Engine<T>
impl<T> Unpin for Engine<T>
impl<T> UnsafeUnpin for Engine<T>
impl<T> !UnwindSafe for Engine<T>
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