macron_collections/
btree_map.rs

1/// Creates a collection [BTreeMap](std::collections::BTreeMap)
2#[macro_export]
3macro_rules! btree_map {
4    ($($tt:tt)*) => {{
5        ::std::collections::BTreeMap::from( ::macron_map::map!( $($tt)* ) )
6    }};
7}
8
9/// Creates a collection [BTreeMap](std::collections::BTreeMap) with auto type converting by [Into::into()](std::convert::Into)
10#[macro_export]
11macro_rules! auto_btree_map {
12    ($($tt:tt)*) => {{
13        let fields = ::macron_map::map!($($tt)*);
14        let map: ::std::collections::BTreeMap<String, _> = fields
15            .into_iter()
16            .map(|(k, v)| (k.into(), v.into()))
17            .collect();
18        map
19    }};
20}
21
22/// Creates a stringify collection [BTreeMap](std::collections::BTreeMap)
23#[macro_export]
24macro_rules! str_btree_map {
25    ($($tt:tt)*) => {{
26        let fields = ::macron_map::map!($($tt)*);
27        let map: ::std::collections::BTreeMap<String, _> = fields
28            .into_iter()
29            .map(|(k, v)| (String::from(k), String::from(v)))
30            .collect();
31        map
32    }};
33}