Skip to content

Commit 8719f50

Browse files
committed
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.
2 parents 78edd4f + 8013000 commit 8719f50

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/libcore/str/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ pub trait FromStr: Sized {
4848
/// If parsing succeeds, return the value inside `Ok`, otherwise
4949
/// when the string is ill-formatted return an error specific to the
5050
/// inside `Err`. The error type is specific to implementation of the trait.
51+
///
52+
/// # Examples
53+
///
54+
/// Basic usage with [`i32`][ithirtytwo], a type that implements `FromStr`:
55+
///
56+
/// [ithirtytwo]: ../primitive.i32.html
57+
///
58+
/// ```
59+
/// use std::str::FromStr;
60+
///
61+
/// let s = "5";
62+
/// let x = i32::from_str(s).unwrap();
63+
///
64+
/// assert_eq!(5, x);
65+
/// ```
5166
#[stable(feature = "rust1", since = "1.0.0")]
5267
fn from_str(s: &str) -> Result<Self, Self::Err>;
5368
}

0 commit comments

Comments
 (0)