Macro wwsvc_rs::collection
source · macro_rules! collection { ($($k:expr => $v:expr),* $(,)?) => { ... }; ($($v:expr),* $(,)?) => { ... }; }
Expand description
Generates a collection with syntactic sugar for vecs, sets and maps.
§Example
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use wwsvc_rs::collection;
let s: Vec<_> = collection![1, 2, 3];
println!("{:?}", s);
let s: BTreeSet<_> = collection!{ 1, 2, 3 };
println!("{:?}", s);
let s: HashSet<_> = collection!{ 1, 2, 3 };
println!("{:?}", s);
let s: BTreeMap<_, _> = collection!{ 1 => 2, 3 => 4 };
println!("{:?}", s);
let s: HashMap<_, _> = collection!{ 1 => 2, 3 => 4 };
println!("{:?}", s);