#declarative-macro #binary-heap #macro

macron-collections

Creates a new instance of std collections: HashMap, HashSet, BTreeMap, BTreeSet, VecDeque, LinkedList and BinaryHeap

5 releases

0.1.5 Jan 1, 2026
0.1.4 Dec 29, 2025
0.1.3 May 30, 2025
0.1.2 May 30, 2025
0.1.0 May 25, 2025

#1661 in Rust patterns

Download history 27/week @ 2025-09-18 31/week @ 2025-09-25 16/week @ 2025-10-02 10/week @ 2025-10-09 39/week @ 2025-10-16 20/week @ 2025-10-23 9/week @ 2025-10-30 12/week @ 2025-11-06 15/week @ 2025-11-13 16/week @ 2025-11-20 20/week @ 2025-11-27 11/week @ 2025-12-04 13/week @ 2025-12-11 24/week @ 2025-12-18 19/week @ 2025-12-25 13/week @ 2026-01-01

73 downloads per month
Used in 5 crates (via macron)

MIT license

7KB
69 lines

githubcrates-iodocs-rs

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.

Dependencies

~135–530KB
~13K SLoC