Expand description
§Std::Collections Declarative Macros
§Introduction:
Creates a new instance of std collections: HashMap, HashSet, BTreeMap, BTreeSet, VecDeque, LinkedList and BinaryHeap.
P.s.: More useful macros you can find here.
§Examples:
VecDeque
let mut deque = vec_deque![1, 2, 3];
assert_eq!(deque.len(), 3);
assert_eq!(deque.pop_front(), Some(1));
assert_eq!(deque.pop_back(), Some(3));HashMap
let key = "one";
let val = 1;
let map = hash_map! {
key => val,
"two": 2,
"three" => 3,
"four": 4
};
assert_eq!(map.get("one"), Some(&1));
assert_eq!(map.get("two"), Some(&2));HashSet
let set = hash_set![1, 2, 3];
assert!(set.contains(&1));
assert!(set.contains(&2));BTreeMap
let key = "one";
let val = 1;
let map = btree_map! {
key => val,
"two": 2,
"three" => 3,
"four": 4
};
assert_eq!(map.get("one"), Some(&1));
assert_eq!(map.get("two"), Some(&2));BTreeSet
let set = btree_set![4, 5, 6];
assert!(set.contains(&4));
assert!(set.contains(&5));BinaryHeap
let mut heap = binary_heap![3, 1, 2];
assert_eq!(heap.pop(), Some(3));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));LinkedList
let mut list = linked_list![10, 20, 30];
assert_eq!(list.len(), 3);
assert_eq!(list.pop_front(), Some(10));
assert_eq!(list.pop_back(), Some(30));§Licensing:
Distributed under the MIT license.
§Feedback:
You can contact me via GitHub or send a message to my Telegram @fuderis.
This library is constantly evolving, and I welcome your suggestions and feedback.
Re-exports§
pub use macron_map;
Modules§
Macros§
- binary_
heap - Creates a collection BinaryHeap
- btree_
map - Creates a collection BTreeMap
- btree_
set - Creates a collection BTreeSet
- hash_
map - Creates a collection HashMap
- hash_
set - Creates a collection HashSet
- linked_
list - Creates a collection LinkedList
- map
- The key-value collection parser
- vec_
deque - Creates a collection VecDeque