[][src]Trait num_traits::Num

pub trait Num: PartialEq + Zero + One + NumOps {
    type FromStrRadixErr;
    fn from_str_radix(
        str: &str,
        radix: u32
    ) -> Result<Self, Self::FromStrRadixErr>; }

The base trait for numeric types, covering 0 and 1 values, comparisons, basic numeric operations, and string conversion.

Associated Types

type FromStrRadixErr

Loading content...

Required methods

fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix <= 36.

Examples

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());
Loading content...

Implementations on Foreign Types

impl<T: Num> Num for Wrapping<T> where
    Wrapping<T>: Add<Output = Wrapping<T>> + Sub<Output = Wrapping<T>> + Mul<Output = Wrapping<T>> + Div<Output = Wrapping<T>> + Rem<Output = Wrapping<T>>, 
[src]

type FromStrRadixErr = T::FromStrRadixErr

Loading content...

Implementors

impl Num for f32[src]

type FromStrRadixErr = ParseFloatError

impl Num for f64[src]

type FromStrRadixErr = ParseFloatError

impl Num for i8[src]

type FromStrRadixErr = ParseIntError

impl Num for i16[src]

type FromStrRadixErr = ParseIntError

impl Num for i32[src]

type FromStrRadixErr = ParseIntError

impl Num for i64[src]

type FromStrRadixErr = ParseIntError

impl Num for i128[src]

type FromStrRadixErr = ParseIntError

impl Num for isize[src]

type FromStrRadixErr = ParseIntError

impl Num for u8[src]

type FromStrRadixErr = ParseIntError

impl Num for u16[src]

type FromStrRadixErr = ParseIntError

impl Num for u32[src]

type FromStrRadixErr = ParseIntError

impl Num for u64[src]

type FromStrRadixErr = ParseIntError

impl Num for u128[src]

type FromStrRadixErr = ParseIntError

impl Num for usize[src]

type FromStrRadixErr = ParseIntError

Loading content...