Skip to content

Commit

Permalink
Change fmt docs for more delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed Dec 12, 2019
1 parent f284f8b commit 0cc8fe5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/libcore/fmt/mod.rs
Expand Up @@ -455,7 +455,10 @@ impl Display for Arguments<'_> {
///
/// impl fmt::Debug for Point {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y)
/// f.debug_struct("Point")
/// .field("x", &self.x)
/// .field("y", &self.y)
/// .finish()
/// }
/// }
///
Expand Down Expand Up @@ -528,7 +531,10 @@ pub trait Debug {
///
/// impl fmt::Debug for Position {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "({:?}, {:?})", self.longitude, self.latitude)
/// f.debug_tuple("")
/// .field(&self.longitude)
/// .field(&self.latitude)
/// .finish()
/// }
/// }
///
Expand Down Expand Up @@ -912,8 +918,8 @@ pub trait Pointer {
///
/// impl fmt::LowerExp for Length {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
/// write!(f, "{}e1", val / 10)
/// let val = f64::from(self.0);
/// fmt::LowerExp::fmt(&val, f) // delegate to f64's implementation
/// }
/// }
///
Expand Down Expand Up @@ -955,8 +961,8 @@ pub trait LowerExp {
///
/// impl fmt::UpperExp for Length {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
/// write!(f, "{}E1", val / 10)
/// let val = f64::from(self.0);
/// fmt::UpperExp::fmt(&val, f) // delegate to f64's implementation
/// }
/// }
///
Expand Down

0 comments on commit 0cc8fe5

Please sign in to comment.