Features
- Collection Macros: Easy creation of
HashMap,HashSet,BTreeMap,BTreeSet, andVecDeque - Type Conversion:
_intovariants that automatically convert values to target types - Regular Expressions: Static regex compilation for efficient pattern matching
- Utility Macros: Helper macros for counting and other operations
Installation
Addbomboni_macros to your Cargo.toml:
HashMap Creation
CreateHashMap instances with a convenient syntax:
HashMap with Type Conversion
Usehash_map_into! to automatically convert keys and values:
HashSet Creation
CreateHashSet instances with ease:
HashSet with Type Conversion
BTreeMap Creation
Create sortedBTreeMap instances:
BTreeMap with Type Conversion
BTreeSet Creation
Create sortedBTreeSet instances:
BTreeSet with Type Conversion
VecDeque Creation
Create double-ended queue instances:VecDeque with Type Conversion
Regular Expression Macro
Create static, lazily-compiled regular expressions:Common Regex Patterns
Counting Macro
Count the number of repeated elements:The
count_repeating! macro is primarily used internally by other collection macros to pre-allocate capacity, but it’s available for general use.Macro Comparison
Regular vs Into Variants
Performance Considerations
Practical Examples
Configuration Map
Static Lookup Tables
Validation Sets
API Reference
Collection Macros
Creates a
HashMap with optional capacity or key-value pairs.Syntax:hash_map!()- Empty maphash_map!(capacity)- Map with pre-allocated capacityhash_map!{ k1 => v1, k2 => v2, ... }- Map with initial values
Creates a
HashMap with automatic type conversion using Into.Syntax: hash_map_into!{ k1 => v1, k2 => v2, ... }Creates a
HashSet with optional values.Syntax:hash_set!()- Empty sethash_set![v1, v2, v3, ...]- Set with initial values
Creates a
HashSet with automatic type conversion.Syntax: hash_set_into![v1, v2, v3, ...]Creates a sorted
BTreeMap with key-value pairs.Syntax:btree_map!()- Empty mapbtree_map!{ k1 => v1, k2 => v2, ... }- Map with initial values
Creates a
BTreeMap with automatic type conversion.Syntax: btree_map_into!{ k1 => v1, k2 => v2, ... }Creates a sorted
BTreeSet with values.Syntax:btree_set!()- Empty setbtree_set![v1, v2, v3, ...]- Set with initial values
Creates a
BTreeSet with automatic type conversion.Syntax: btree_set_into![v1, v2, v3, ...]Creates a
VecDeque with values.Syntax:vec_deque!()- Empty dequevec_deque![v; n]- Deque withncopies ofvvec_deque![v1, v2, v3, ...]- Deque with initial values
Creates a
VecDeque with automatic type conversion.Syntax: vec_deque_into![v1, v2, v3, ...]Utility Macros
Creates a static, lazily-compiled
Regex instance.Syntax: regex!(pattern)Returns: &'static RegexPanics: If the regex pattern is invalidCounts the number of repeated elements in a macro invocation.Syntax:
count_repeating!(expr1, expr2, ...)Returns: usize - The count of elementsRelated Modules
bomboni_common
Common utilities and types
bomboni_core
Core utilities and abstractions