Enum variants: a small problem, a lot of headache and boilerplate
The Rust Programming Language Forum
Enum variants: a small problem, a lot of headache and boilerplate
Enum variants can create a surprisingly annoying problem when they contain unrelated types that happen to support the same operation. Consider: enum Value { Foo(Foo), Bar(Bar), } Both Foo and Bar have a value() method, but they are otherwise unrelated types. The straightforward Rust solution is: match value { Value::Foo(x) => x.value(), Value::Bar(x) => x.value(), } Nothing is wrong with this code. The problem starts when the enum grows, or when you need to perform many dif...
0 comments
No comments yet.