concrete-type-rules
Utilities and extensions for working with the concrete-type crate, providing macros for composing multiple concrete enum types.
Table of Contents
Overview
concrete-type-rules extends the functionality of the concrete-type crate by providing utilities for working with multiple concrete enum types simultaneously. This enables:
- Composing multiple enum types together through generated macros
- Reducing nesting and improving code readability
- Creating type-safe interfaces for generic components
- Supporting up to 5 enum types in a single match expression
Installation
Add this to your Cargo.toml:
[]
= "0.2.0"
= "0.1.0"
Features
gen_match_concretes_macro!
The gen_match_concretes_macro! macro generates a new macro that allows you to match multiple enum instances simultaneously, providing type parameters for each concrete type associated with the enum variants.
Supports from 2 to 5 enum types.
Examples
Combined Matcher for Two Enum Types
use Concrete;
use gen_match_concretes_macro;
// Generate a combined matcher macro
gen_match_concretes_macro!;
// Now you can use the generated macro with both enum instances
let exchange = Binance;
let strategy = StrategyA;
// This uses a single match expression for both enums
let result = match_exchange_strategy!;
Using With More Enum Types
The macro supports up to 5 enum types:
// For 3 enum types:
gen_match_concretes_macro!;
// Generated macro name combines all enum names in snake_case
// E.g., match_exchange_strategy_market!
// For 4 or 5 enum types:
gen_match_concretes_macro!;
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT