eval
Eval is a powerful expression evaluator.
Document
Features
Supported operators: ! != "" '' () [] , > < >= <= ==
+ - * / % && || n..m.
Built-in functions: min() max() len() is_empty() array().
Where can eval be used?
- Template engine
- ...
Usage
Add dependency to Cargo.toml
[]
= "^0.4"
In your main.rs or lib.rs:
extern crate eval;
Examples
You can do mathematical calculations with supported operators:
use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
You can eval with context:
use ;
assert_eq!;
You can access data like javascript by using . and []. [] supports expression.
use ;
use HashMap;
let mut object = new;
object.insert;
assert_eq!;
You can eval with function:
use ;
assert_eq!;
You can create an array with array():
use ;
assert_eq!;
You can create an integer array with n..m:
use ;
assert_eq!;
License
eval is primarily distributed under the terms of the MIT license. See LICENSE for details.