Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Extracting value from an enum (more thoughts)
Strange, I thought it's trivial in Rust, but I do not see how. I have an enum with about ten cases. I know that I have a particular case and I want to get its value. But I do not see any way doing that except match.
match out.get("name") {
Some(name) if matches!(name, Text(_)) => match name {
Text(val) => val,
_ => unreachable!(),
},
_ => "simhttp-${0}"
}
Can we close the topic?
3 posts - 2 participants
🏷️ rust_feed