Skip to content

Commit

Permalink
Add another implementation example to Debug trait
Browse files Browse the repository at this point in the history
  • Loading branch information
alper committed Dec 27, 2021
1 parent f8abed9 commit 1773e83
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,26 @@ impl Display for Arguments<'_> {
/// There are a number of helper methods on the [`Formatter`] struct to help you with manual
/// implementations, such as [`debug_struct`].
///
/// [`debug_struct`]: Formatter::debug_struct
///
/// For custom cases, it's also possible to implement `Debug` using the [`write!`] macro:
/// ```
/// # use std::fmt;
/// # struct Point {
/// # x: i32,
/// # y: i32,
/// # }
///
/// impl fmt::Debug for Point {
/// fn fmt(&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {
/// write!(f, "Point [{} {}]", self.x, self.y)
/// }
/// }
/// ```
///
/// `Debug` implementations using either `derive` or the debug builder API
/// on [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`.
///
/// [`debug_struct`]: Formatter::debug_struct
///
/// Pretty-printing with `#?`:
///
/// ```
Expand Down

0 comments on commit 1773e83

Please sign in to comment.