Skip to content

Commit

Permalink
Add some docs for FromString::from_str
Browse files Browse the repository at this point in the history
@marchelzo pointed out on IRC that this doesn't have docs, so, let's
change that.
  • Loading branch information
steveklabnik committed Sep 30, 2015
1 parent 3e6d724 commit 8013000
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libcore/str/mod.rs
Expand Up @@ -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>;
}
Expand Down

0 comments on commit 8013000

Please sign in to comment.