Match-variants 0.1.0 — Apply the same expression to heterogeneous enum variants without a common trait
The Rust Programming Language Forum
Match-variants 0.1.0 — Apply the same expression to heterogeneous enum variants without a common trait
I’ve published match-variants, a small procedural macro crate for applying the same expression to heterogeneous enum variants without requiring their payload types to implement a common trait. The problem I wanted to solve is code like this: match value { Value::Foo(x) => x.value(), Value::Bar(x) => x.value(), } where Foo and Bar are unrelated concrete types, but the same expression happens to be valid for both. With match-variants: #[derive(MatchVariants)] enum Value { Foo(Foo)...
0 comments
No comments yet.