resolver
Source
This work is a derivative of this repository: https://github.com/fengcen/eval
The aforementioned repository has been abandoned, hence the reason for this repository/crate.
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.1"
In your main.rs
or lib.rs
:
extern crate resolver;
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
resolver is under the terms of the GPL-3.0-only license.
See LICENSE for details.