I wish I can print a structure like an anonymous structure by specifying an empty structure name using Formatter::debug_struct, for example:
struct Item;
impl Debug for Item {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("").field("x", &2).finish()
}
}
I expect format!("{:?}", Item) to be "{ x: 2 }", instead, I get " { x: 2 }".
I wish I can print a structure like an anonymous structure by specifying an empty structure name using
Formatter::debug_struct, for example:I expect
format!("{:?}", Item)to be"{ x: 2 }", instead, I get" { x: 2 }".