pub struct Function { /* 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::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(4)));
Implementations
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl !UnwindSafe for Function
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more