pub struct ExprWrapper { /* private fields */ }
Implementations§
Source§impl ExprWrapper
impl ExprWrapper
Sourcepub fn new<S: AsRef<str>>(expression: S) -> ExprWrapper
pub fn new<S: AsRef<str>>(expression: S) -> ExprWrapper
Examples found in repository?
examples/example.rs (line 8)
3fn main() {
4 let expression = "float('42.42') == 42.42";
5 let expected = true;
6
7
8 let mut expr = ExprWrapper::new(expression)
9 // .config(Default::default())
10 .config(EvalConfig { // same as Default::default() ^
11 include_maths: true,
12 include_regex: true,
13 include_datetime: true,
14 include_cast: true,
15 })
16 .init();
17
18 match expr.exec() {
19 Ok(value) => {
20 assert_eq!(value, expected);
21 }
22 Err(_err) => {
23 panic!("err={_err:?}");
24 }
25 };
26 // ...
27}
Sourcepub fn config(self, config: EvalConfig) -> ExprWrapper
pub fn config(self, config: EvalConfig) -> ExprWrapper
Examples found in repository?
examples/example.rs (lines 10-15)
3fn main() {
4 let expression = "float('42.42') == 42.42";
5 let expected = true;
6
7
8 let mut expr = ExprWrapper::new(expression)
9 // .config(Default::default())
10 .config(EvalConfig { // same as Default::default() ^
11 include_maths: true,
12 include_regex: true,
13 include_datetime: true,
14 include_cast: true,
15 })
16 .init();
17
18 match expr.exec() {
19 Ok(value) => {
20 assert_eq!(value, expected);
21 }
22 Err(_err) => {
23 panic!("err={_err:?}");
24 }
25 };
26 // ...
27}
Sourcepub fn init(self) -> ExprWrapper
pub fn init(self) -> ExprWrapper
Examples found in repository?
examples/example.rs (line 16)
3fn main() {
4 let expression = "float('42.42') == 42.42";
5 let expected = true;
6
7
8 let mut expr = ExprWrapper::new(expression)
9 // .config(Default::default())
10 .config(EvalConfig { // same as Default::default() ^
11 include_maths: true,
12 include_regex: true,
13 include_datetime: true,
14 include_cast: true,
15 })
16 .init();
17
18 match expr.exec() {
19 Ok(value) => {
20 assert_eq!(value, expected);
21 }
22 Err(_err) => {
23 panic!("err={_err:?}");
24 }
25 };
26 // ...
27}
pub fn value<T, V>(self, name: T, value: V) -> ExprWrapper
pub fn function<T, F>(self, name: T, function: F) -> ExprWrapper
Sourcepub fn exec(&mut self) -> Result<Value, Error>
pub fn exec(&mut self) -> Result<Value, Error>
Examples found in repository?
examples/example.rs (line 18)
3fn main() {
4 let expression = "float('42.42') == 42.42";
5 let expected = true;
6
7
8 let mut expr = ExprWrapper::new(expression)
9 // .config(Default::default())
10 .config(EvalConfig { // same as Default::default() ^
11 include_maths: true,
12 include_regex: true,
13 include_datetime: true,
14 include_cast: true,
15 })
16 .init();
17
18 match expr.exec() {
19 Ok(value) => {
20 assert_eq!(value, expected);
21 }
22 Err(_err) => {
23 panic!("err={_err:?}");
24 }
25 };
26 // ...
27}
Trait Implementations§
Source§impl Clone for ExprWrapper
impl Clone for ExprWrapper
Source§fn clone(&self) -> ExprWrapper
fn clone(&self) -> ExprWrapper
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ExprWrapper
impl !RefUnwindSafe for ExprWrapper
impl !Send for ExprWrapper
impl !Sync for ExprWrapper
impl Unpin for ExprWrapper
impl !UnwindSafe for ExprWrapper
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