format!("{:#?}", (100, 200)); // => "(
// 100,
// 200,
// )"
Any docs to elaborate on this pattern {:#?}
?
format!("{:#?}", (100, 200)); // => "(
// 100,
// 200,
// )"
Any docs to elaborate on this pattern {:#?}
?
?
means a debug format (use Debug
and not Display
), #
means pretty-printing the debug format. For example:
#[derive(Debug)]
struct S {
a: i32,
b: i32,
}
fn main() {
let v = S { a: 1, b: 2 };
println!("{v:?}");
println!("{v:#?}");
}
Prints (Playground):
S { a: 1, b: 2 }
S {
a: 1,
b: 2,
}
See the docs.