Hi All,
Hopefully a simple syntax question.
In a match, is there some way I can say "I don't care about the specific variant as long as it has an associated value"?
Given an enum like this:
enum Ex {
VarOne,
VarTwo,
VarThree( AssocOne ),
VarFour( AssocTwo ),
}
And assuming that AssocOne
and AssocTwo
both implement a trait Foo
with function my_trait_func
...
How do I do the match in the following?
impl Foo for Ex {
fn my_trait_func( &self, x : something ) {
match self {
VarOne => x.magic( "One" ),
VarTwo => x.magic( "Two" ),
_( t ) => t.my_trait_func( x ),
}
}
}
The above gives me the error:
expected one of =>
, if
, or |
, found (
If I change the _
to Ex
I get the error:
expected tuple struct or tuple variant, found enum 'Ex'