Crates.io | mapro |
lib.rs | mapro |
version | 0.1.1 |
source | src |
created_at | 2023-09-25 09:15:14.151295 |
updated_at | 2023-09-25 09:17:25.457675 |
description | A tiny macro library for creating std::collections |
homepage | |
repository | https://github.com/snowfoxsh/mapro |
max_upload_size | |
id | 982515 |
size | 8,696 |
A tiny macro library for creating std::collections
.
mapro
provides a set of convenient macros for creating various standard library collections, such as HashMap
, BTreeMap
, HashSet
, BTreeSet
, VecDeque
, and BinaryHeap
.
The name mapro
is a portmanteau of "macro" and "map", but the library handles more than just map types.
To use mapro
, add it to your Cargo.toml
dependencies:
[dependencies]
mapro = "0.1.0"
or run:
cargo add mapro
Then import the macros you want to use in your Rust files:
use mapro::{map, bt_map, set, bt_set, vec_d, heap};
Creating a HashMap
:
let m = map!{
"one" => 1,
"two" => 2
};
assert_eq!(m["one"], 1);
assert_eq!(m["two"], 2);
Creating a HashSet
:
let s = set!{1, 2, 3};
assert!(s.contains(&1));
assert!(s.contains(&2));
assert!(s.contains(&3));
Simple API: Using mapro
is as straightforward as using any Rust macro.
No Extra Dependencies: mapro
only depends on the standard library.
Broad Collection Support: Supports various standard library collections out of the box.
Interested in contributing? Submit a pull request!
This project is licensed under the MIT License.