#![allow(dead_code, deprecated, unused_variables, unused_mut)] use std::fmt; struct Foo { bar: i32, baz: String, } impl fmt::Debug for Foo { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Foo").field("bar", &self.bar).field("baz", &self.baz).finish() } } fn main() { assert_eq!( format!("{:?}", Foo { bar : 10, baz : "Hello World".to_string() }), r#"Foo { bar: 10, baz: "Hello World" }"#, ); }