about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-04-10 13:07:35 +0000
committerbors <bors@rust-lang.org>2017-04-10 13:07:35 +0000
commit8493dd6d6e8f5e1280ae3dc05135a7e2897c36ac (patch)
tree1e11f83d68f202615c553561ac824f0d02bff6df /src/libcore
parent2bdf368bdec589c689950e88eec973cd5df658fc (diff)
parent1e7f3551d161ace63264b466707c0a1c5c589fb9 (diff)
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.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/fmt/mod.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 0bfab92fa5d..8c3d3ce7d88 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -49,8 +49,31 @@ pub mod rt {
     pub mod v1;
 }
 
-#[stable(feature = "rust1", since = "1.0.0")]
 /// The type returned by formatter methods.
+///
+/// # Examples
+///
+/// ```
+/// use std::fmt;
+///
+/// #[derive(Debug)]
+/// struct Triangle {
+///     a: f32,
+///     b: f32,
+///     c: f32
+/// }
+///
+/// impl fmt::Display for Triangle {
+///     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+///         write!(f, "({}, {}, {})", self.a, self.b, self.c)
+///     }
+/// }
+///
+/// let pythagorean_triple = Triangle { a: 3.0, b: 4.0, c: 5.0 };
+///
+/// println!("{}", pythagorean_triple);
+/// ```
+#[stable(feature = "rust1", since = "1.0.0")]
 pub type Result = result::Result<(), Error>;
 
 /// The error type which is returned from formatting a message into a stream.