Skip to content

Commit

Permalink
Rollup merge of rust-lang#92322 - alper:add_debug_trait_documentation…
Browse files Browse the repository at this point in the history
…, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: rust-lang#92276
  • Loading branch information
matthiaskrgr committed Jan 5, 2022
2 parents 2e0b081 + 4df1a55 commit b42ea50
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,30 @@ 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
///
/// Types that do not wish to use the standard suite of debug representations
/// provided by the `Formatter` trait (`debug_struct`, `debug_tuple`,
/// `debut_list`, `debug_set`, `debug_map`) can do something totally custom by
/// manually writing an arbitrary representation to the `Formatter`.
///
/// ```
/// # 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 b42ea50

Please sign in to comment.