Merge pull request #258 from frewsxcv/patch-1

Add doc example for `num_traits::Num::from_str_radix`.
This commit is contained in:
Josh Stone 2017-01-31 09:37:30 -08:00 committed by GitHub
commit ba54797d60
1 changed files with 12 additions and 0 deletions

View File

@ -43,6 +43,18 @@ pub trait Num: PartialEq + Zero + One
type FromStrRadixErr;
/// Convert from a string and radix <= 36.
///
/// # Examples
///
/// ```rust
/// use num_traits::Num;
///
/// let result = <i32 as Num>::from_str_radix("27", 10);
/// assert_eq!(result, Ok(27));
///
/// let result = <i32 as Num>::from_str_radix("foo", 10);
/// assert!(result.is_err());
/// ```
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>;
}