Sac
A rust macro that will construct an instance of any collection that implements FromIterator.
Cargo.toml
[]
= "0.2"
main.rs
extern crate sac;
No type annotations are needed if the compiler can infer the types:
;
let container = VecWrapper;
Trailing commas are also supported:
let vec: = sac!;
assert_eq!;
The macro can also construct maps (e.g. HashMap) with struct-like syntax:
let map_with_syntax_sugar: = sac! ;
let map_without_syntax_sugar: = sac! ;
assert_eq!;
Variables can be used as keys and values:
let key = "foo";
let value = "bar";
let map: = sac! ;
assert_eq!;
To use expressions as keys, surround them with parentheses or braces:
let map: = sac! ;
assert_eq!;