An open API service indexing awesome lists of open source software.

https://github.com/floating-floaties/eval-utility

Wrapper function of the resolver crate. Provides python-like built-in functions.
https://github.com/floating-floaties/eval-utility

rust

Last synced: 8 days ago
JSON representation

Wrapper function of the resolver crate. Provides python-like built-in functions.

Awesome Lists containing this project

README

          

# Eval Utility

* [Eval Utility](#eval-utility)
* [About](#about)
* [Install](#install)
* [Example](#example)

## About

Wrapper function of the [resolver crate](https://crates.io/crates/resolver). Provides python-like built-in functions.

## Install
Add the following line to your Cargo.toml file (under `[dependencies]`):

```toml
eval-utility = "0.2"
```

## Example

See test cases in [`lib.rs`](https://github.com/floating-floaties/eval-utility/blob/main/src/lib.rs#L484) for more examples.

```rust
use eval_utility::eval_wrapper::{EvalConfig, ExprWrapper};

fn main() {
let expression = "float('42.42') == 42.42";
let expected = true;

let mut expr = ExprWrapper::new(expression)
// .config(Default::default())
.config(EvalConfig { // same as Default::default() ^
include_maths: true,
include_regex: true,
include_datetime: true,
include_cast: true,
})
.init();

match expr.exec() {
Ok(value) => {
assert_eq!(value, expected);
}
Err(err) => {
panic!("err={err:?}");
}
};
// ...
}
```