pub struct Function<NumericTypes: EvalexprNumericTypes> { /* private fields */ }
Expand description
A user-defined function.
Functions can be used in expressions by storing them in a Context
.
§Examples
use evalexpr::*;
let mut context = HashMapContext::<DefaultNumericTypes>::new();
context.set_function("id".into(), Function::new(|argument| {
Ok(argument.clone())
})).unwrap(); // Do proper error handling here
assert_eq!(eval_with_context("id(4)", &context), Ok(Value::from_int(4)));
Implementations§
Trait Implementations§
Source§impl<NumericTypes: EvalexprNumericTypes> Clone for Function<NumericTypes>
impl<NumericTypes: EvalexprNumericTypes> Clone for Function<NumericTypes>
Auto Trait Implementations§
impl<NumericTypes> Freeze for Function<NumericTypes>
impl<NumericTypes> !RefUnwindSafe for Function<NumericTypes>
impl<NumericTypes> Send for Function<NumericTypes>
impl<NumericTypes> Sync for Function<NumericTypes>
impl<NumericTypes> Unpin for Function<NumericTypes>
impl<NumericTypes> !UnwindSafe for Function<NumericTypes>
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