File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -570,11 +570,26 @@ 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
+ /// For custom cases, it's also possible to implement `Debug` using the [`write!`] macro:
576
+ /// ```
577
+ /// # use std::fmt;
578
+ /// # struct Point {
579
+ /// # x: i32,
580
+ /// # y: i32,
581
+ /// # }
582
+ ///
583
+ /// impl fmt::Debug for Point {
584
+ /// fn fmt(&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {
585
+ /// write!(f, "Point [{} {}]", self.x, self.y)
586
+ /// }
587
+ /// }
588
+ /// ```
589
+ ///
573
590
/// `Debug` implementations using either `derive` or the debug builder API
574
591
/// on [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`.
575
592
///
576
- /// [`debug_struct`]: Formatter::debug_struct
577
- ///
578
593
/// Pretty-printing with `#?`:
579
594
///
580
595
/// ```
You can’t perform that action at this time.
0 commit comments