How to get a string representation of an enum variant in Rust?
Hi everyone! I just started learning Rust and encountered a problem that seems simple, but I can't find an elegant solution.
I have an enum for order statuses:
```rust
enum OrderStatus {
Pending,
Processing,
Shipped,
Delivered,
Cancelled,
}
```
I need to output the current status to the console for logging and for displaying to the user. I tried simply using `println!("{}", status)`, but the compiler gives an error that the `std::fmt::Display` trait is not implemented for my type.
I know that I can add `#[derive(Debug)]` and use `{:?}`, but this gives output like `OrderStatus::Pending`, and I need just "Pending" without the enum name. I also tried writing a match expression for each variant, but it looks very cumbersome.