Let's say I have the structs "F1" and "F2" that implement the Trait "Foo".
Now I want to write a function that accepts Foo and returns Bar.
trait Foo {
fn get_bar(&self) -> &Bar
}
fn do_match(f: &Foo) -> &Bar {
&match *f {
F1 => { f.get_bar() } // Error: mismatched types: expected `Foo`, found an enum or structure pattern
F2 => { f.get_bar().modify_somehow(3f64) }
}
}
Is it possible to match against structs implementing the trait Foo?