Merge pull request #258 from frewsxcv/patch-1
Add doc example for `num_traits::Num::from_str_radix`.
This commit is contained in:
commit
ba54797d60
|
@ -43,6 +43,18 @@ pub trait Num: PartialEq + Zero + One
|
||||||
type FromStrRadixErr;
|
type FromStrRadixErr;
|
||||||
|
|
||||||
/// Convert from a string and radix <= 36.
|
/// 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>;
|
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue