#collection #macro #identifier #keyword

collections_macros

a collection of macros to make making collections easier

2 releases (1 stable)

1.0.1 Feb 17, 2022
0.1.0 Feb 17, 2022

#2635 in Rust patterns

MIT/Apache

4KB
62 lines

some macros for dicts

creates hashmap, hashset, btreeset, btreemap

map has two sytaxts

let a = 1;
let b = 2;
hashmap![
    a: a+b,
    b: b
],

is equal to

std::collections::HashMap::from([(a, a), (b, a + b)])

but if you dont include commas it acts like yml and gets names from ident

hashmap![
    a: a+b
    b: b
],

is equal to

std::collections::HashMap::from([("a", a + b), ("b", b)])

No runtime deps