How to extract the inner value from an enum variant when I know exactly which variant it is?
Hello! I'm writing in Rust and encountered a problem when working with enums. I have code like this:
```rust
enum Message {
Text(String),
Number(i32),
Quit,
}
fn process(msg: Message) {
// I know for sure that msg is Text(String)
// But how do I get the string?
let text = msg; // error here, of course
println!("Message: {}", text);
}
```
I often encounter situations where I know exactly which enum variant I'm handling — for example, after a condition check or in a context where it's guaranteed by the program logic. But Rust doesn't allow simply "unwrapping" an enum and extracting the inner value.
I know about `match`, but writing a whole match with handling all variants when I'm sure about one specific variant seems excessive. Using `if let` seems...