macron-collections

Crates.iomacron-collections
lib.rsmacron-collections
version0.1.3
created_at2025-05-25 04:09:28.981277+00
updated_at2025-05-30 06:30:27.867456+00
descriptionCreates a new instance of std collections: HashMap, HashSet, BTreeMap, BTreeSet, VecDeque, LinkedList and BinaryHeap
homepage
repositoryhttps://github.com/fuderis/rs-macron/tree/main/macron-collections
max_upload_size
id1687997
size16,012
Bulat Sh. (fuderis)

documentation

README

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.

Commit count: 15

cargo fmt