0
format!("{:#?}", (100, 200));     // => "(
                                  //       100,
                                  //       200,
                                  //     )"

Any docs to elaborate on this pattern {:#?}?

1 Answers1

6

? 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.

hackape
  • 18,643
  • 2
  • 29
  • 57
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77