about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-10-01 11:18:48 +0000
committerbors <bors@rust-lang.org>2015-10-01 11:18:48 +0000
commit8719f504ee3c6697a5e76ed65524ecf8a39be2e5 (patch)
tree39796d3e414e668d712fa0ba6f2bf5feee8ecf2e /src
parent78edd4f3a0c614c8deab030351ece9baade848cc (diff)
parent80130005da9eb17563e920747422f375b1d598bc (diff)
downloadrust-8719f504ee3c6697a5e76ed65524ecf8a39be2e5.tar.gz
rust-8719f504ee3c6697a5e76ed65524ecf8a39be2e5.zip
Auto merge of #28780 - steveklabnik:doc_from_str, r=alexcrichton
@marchelzo pointed out on IRC that this doesn't have docs, so, let's
change that.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/str/mod.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index 3c7f1b36883..be2186945d5 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -48,6 +48,21 @@ pub trait FromStr: Sized {
     /// If parsing succeeds, return the value inside `Ok`, otherwise
     /// when the string is ill-formatted return an error specific to the
     /// inside `Err`. The error type is specific to implementation of the trait.
+    ///
+    /// # Examples
+    ///
+    /// Basic usage with [`i32`][ithirtytwo], a type that implements `FromStr`:
+    ///
+    /// [ithirtytwo]: ../primitive.i32.html
+    ///
+    /// ```
+    /// use std::str::FromStr;
+    ///
+    /// let s = "5";
+    /// let x = i32::from_str(s).unwrap();
+    ///
+    /// assert_eq!(5, x);
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn from_str(s: &str) -> Result<Self, Self::Err>;
 }