Given the following code
enum shape {
Circle,
Square,
Rectangle
}
struct A {
b: shape,
c: String
}
struct Plan {
items : Vec<A>
}
impl Plan {
fn draw_shapes() {
self.items.iter().find_map(|d| match ??? { // How to match on a field of struct?
shapes::Circle => draw_circle(d),
shapes::Square => draw_square(d),
shapes::Rectanble => draw_rectangle(d),
})
}
}
}
I want to match a field of struct A
and call the respective draw functions.