anyrust
A library that provides a type system as flexible and powerful as Javascript.
Usage
Usage is simple and intuitive. All you have to do is box the value into the anyrust::Any type and use it appropriately.
Below is a simple example.
use *;
Primitives
The basic integer type, basic float type, boolean type, and string type support mutual conversion with Any without any problem.
Array
Arrays are supported through the anyrust::Array
type. This is compatible with Vec<Any>
.
let mut arr = array!;
arr.push;
arr.push;
for e in arr
Map
KV Map is supported through the anyrust::Map
type. This is compatible with HashMap<Any,Any>
.
let mut map = map!;
map.set;
println!;
for in map.to_map
Function
Function types are provided through the Function
type. You can easily create it with the function!
macro.
let add = function!;
let result = add.call;
println!;
let four: Any = function!;
let result = four.call;
println!;
You can also use function composition through the >> operator.
let add = function!;
let negative = function!;
let composite = add >> negative;
let result = composite.call;
println!; // -3