bomboni_macros crate provides a collection of convenient macros for working with standard library collections, regular expressions, and other common patterns in Rust.
Regular Expression Macros
regex!
Creates a staticregex::Regex instance from a string literal. The regex is compiled once and cached using OnceLock.
Collection Macros
count_repeating!
Counts the number of times a pattern is repeated. Useful for determining the size of a collection at compile time.HashMap Macros
hash_map!
Creates a newHashMap instance with the given key-value pairs or capacity.
hash_map_into!
Creates a newHashMap and converts keys and values using .into().
BTreeMap Macros
btree_map!
Creates a newBTreeMap instance with the given key-value pairs.
btree_map_into!
Creates a newBTreeMap and converts keys and values using .into().
HashSet Macros
hash_set!
Creates a newHashSet and inserts the given values.
hash_set_into!
Creates a newHashSet and converts values using .into().
BTreeSet Macros
btree_set!
Creates a newBTreeSet and inserts the given values.
btree_set_into!
Creates a newBTreeSet and converts values using .into().
VecDeque Macros
vec_deque!
Creates a newVecDeque instance with the given values.
vec_deque_into!
Creates a newVecDeque and converts values using .into().
Complete Examples
Building Configuration Maps
Working with Sets
Pattern Matching with Regex
Type Conversion with _into! Variants
Macro Comparison
| Macro | Purpose | Conversion |
|---|---|---|
hash_map! | Create HashMap | No conversion |
hash_map_into! | Create HashMap | Calls .into() |
btree_map! | Create BTreeMap | No conversion |
btree_map_into! | Create BTreeMap | Calls .into() |
hash_set! | Create HashSet | No conversion |
hash_set_into! | Create HashSet | Calls .into() |
btree_set! | Create BTreeSet | No conversion |
btree_set_into! | Create BTreeSet | Calls .into() |
vec_deque! | Create VecDeque | No conversion |
vec_deque_into! | Create VecDeque | Calls .into() |
_into! variants are useful when you need to convert values to their target types, such as converting &str to String.