File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -570,11 +570,30 @@ impl Display for Arguments<'_> {
570
570
/// There are a number of helper methods on the [`Formatter`] struct to help you with manual
571
571
/// implementations, such as [`debug_struct`].
572
572
///
573
+ /// [`debug_struct`]: Formatter::debug_struct
574
+ ///
575
+ /// Types that do not wish to use the standard suite of debug representations
576
+ /// provided by the `Formatter` trait (`debug_struct`, `debug_tuple`,
577
+ /// `debut_list`, `debug_set`, `debug_map`) can do something totally custom by
578
+ /// manually writing an arbitrary representation to the `Formatter`.
579
+ ///
580
+ /// ```
581
+ /// # use std::fmt;
582
+ /// # struct Point {
583
+ /// # x: i32,
584
+ /// # y: i32,
585
+ /// # }
586
+ /// #
587
+ /// impl fmt::Debug for Point {
588
+ /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
589
+ /// write!(f, "Point [{} {}]", self.x, self.y)
590
+ /// }
591
+ /// }
592
+ /// ```
593
+ ///
573
594
/// `Debug` implementations using either `derive` or the debug builder API
574
595
/// on [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`.
575
596
///
576
- /// [`debug_struct`]: Formatter::debug_struct
577
- ///
578
597
/// Pretty-printing with `#?`:
579
598
///
580
599
/// ```
You can’t perform that action at this time.
0 commit comments