How do we print an ItemEnum?

Sample code:

        for item in file.items.iter() {
            match item {
                Item::Enum(e) => {
                    println!("enum: {:?}", e);
                }

Error:

9 |                     println!("enum: {:?}", e);
   |                                            ^ `ItemEnum` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
   = help: the trait `Debug` is not implemented for `ItemEnum`
   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

However, we have debug.rs - source

So my question is: how do we print an ItemEnum ?

ItemEnum: ItemEnum in syn - Rust

impl Debug for ItemEnum

Available on crate feature extra-traits only.

https://docs.rs/syn/2.0.29/syn/struct.ItemEnum.html#impl-Debug-for-ItemEnum

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.