pub struct ConstantResolver<S, T>where
S: ResolverState,{ /* private fields */ }Expand description
A resolver that always returns the same value regardless of the variable or function name.
§Advantages
- Best performance between all resolvers.
§Disadvantages
- Always returns the same value regardless of the variable or function name.
§Examples
use fee::prelude::*;
use fee::{ EmptyResolver, ConstantResolver };
let expr = "x + y";
let var_resolver = ConstantResolver::new(1.0);
let context = Context::new(var_resolver, EmptyResolver::new());
let mut stack = Vec::new();
let expr = Expr::compile(expr, &context).unwrap();
let result = expr.eval(&context, &mut stack).unwrap();
assert_eq!(result, 2.0);Implementations§
Source§impl<S, T> ConstantResolver<S, T>where
S: ResolverState,
impl<S, T> ConstantResolver<S, T>where
S: ResolverState,
Trait Implementations§
Auto Trait Implementations§
impl<S, T> Freeze for ConstantResolver<S, T>
impl<S, T> RefUnwindSafe for ConstantResolver<S, T>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, T> Send for ConstantResolver<S, T>
impl<S, T> Sync for ConstantResolver<S, T>
impl<S, T> Unpin for ConstantResolver<S, T>
impl<S, T> UnwindSafe for ConstantResolver<S, T>where
T: UnwindSafe,
S: UnwindSafe,
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