delegate-match
Convenience macro for writing grouped match arms for different underlying types.
Writing repetitive match arms for enumerations (or other pattern-matching
constructs) — especially when types, but not the API, differ —
can quickly become boilerplate. delegate_match! lets you list
several patterns up-front once and then re-uses a single body for each
of them, automatically expanding into equivalent ordinary Rust code.
Examples
Delegating to the same code for multiple enum variants
use delegate_match;
let ev = Scroll;
delegate_match!
Using placeholders
use delegate_match;
let msg = Log;
delegate_match!
Examples in tests/
See tests/ for more usage examples. These are verified by the CI to compile and execute successfully.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
See COPYRIGHT for more details.