Skip to content

Commit 8493dd6

Browse files
committed
Auto merge of #41179 - mandeep:add-fmtresult-example, r=frewsxcv
Added doc comments for fmt::Result Added doc comments for fmt::Result in regards to item 3 in issue #29355. I'm not certain that this is all that's needed but I think it's a good starting point on this item.
2 parents 2bdf368 + 1e7f355 commit 8493dd6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/libcore/fmt/mod.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,31 @@ pub mod rt {
4949
pub mod v1;
5050
}
5151

52-
#[stable(feature = "rust1", since = "1.0.0")]
5352
/// The type returned by formatter methods.
53+
///
54+
/// # Examples
55+
///
56+
/// ```
57+
/// use std::fmt;
58+
///
59+
/// #[derive(Debug)]
60+
/// struct Triangle {
61+
/// a: f32,
62+
/// b: f32,
63+
/// c: f32
64+
/// }
65+
///
66+
/// impl fmt::Display for Triangle {
67+
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68+
/// write!(f, "({}, {}, {})", self.a, self.b, self.c)
69+
/// }
70+
/// }
71+
///
72+
/// let pythagorean_triple = Triangle { a: 3.0, b: 4.0, c: 5.0 };
73+
///
74+
/// println!("{}", pythagorean_triple);
75+
/// ```
76+
#[stable(feature = "rust1", since = "1.0.0")]
5477
pub type Result = result::Result<(), Error>;
5578

5679
/// The error type which is returned from formatting a message into a stream.

0 commit comments

Comments
 (0)