Hello, i have the following enum:
enum FlowChartNode {
Squared {id:String, label:Option<String>},
Stadium {id:String, label:Option<String>},
}
and I would like to match a FlowCharNode with the following:
impl Display for FlowChartNode {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
FlowChartNode::Squared {ref id, Some(label)} => write!(f, "{}", id),
FlowChartNode::Stadium {ref id, Some(label)} => write!(f, "{}", id),
}
}
}
I then receive the following error:
error: expected
,
|
| FlowChartNode::Squared {ref id, Some(label)} => write!(f, "{}", id),
| ---------------------- ^
| |
| while parsing the fields for this pattern
I also get the following but it definitely looks like a side effect:
error[E0425]: cannot find value
id
in this scope
|
33 | FlowChartNode::Squared {ref id, Some(label)} => write!(f, "{}", id),
| ^^ not found in this scope
|
help: consider importing this function
|
1 | use std::process::id;
|
I don't realize why my pattern is not valid, thank you for your help.