#![allow(unused)]
#[derive(Debug)]
enum E {
V1,
}
#[derive(Debug)]
enum Message {
Text(String),
Number(i32),
}
fn main() {
let v1 = E::V1;
println!("{:?}", v1);
let msg = Message::Number(5);
println!("{:?}", msg);
}
Output:
V1
Number(5)
Errors:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 2.18s
Running `target/debug/playground`
- I want to print enum v1 with enum name and variant - either as E::V1 or E(v1) - as long as both are printed.
Do I have to implement fmt debug for E?
impl std::fmt::Debug for E
There is no out of the box - print both (enum name and variant)?
-
How about crate strum_macros or strum?
How to print E::v1 -
How about enum Message?
Now I get:
- Number(5)
Can I get:
- Message::Number(5)