[][src]Trait numerics::Num

pub trait Num: Zero + One + NumOps<Self, Self> + PartialEq<Self> {
    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

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 Num for BigUint[src]

type FromStrRadixErr = ParseBigIntError

fn from_str_radix(s: &str, radix: u32) -> Result<BigUint, ParseBigIntError>[src]

Creates and initializes a BigUint.

impl Num for BigInt[src]

type FromStrRadixErr = ParseBigIntError

fn from_str_radix(s: &str, radix: u32) -> Result<BigInt, ParseBigIntError>[src]

Creates and initializes a BigInt.

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

type FromStrRadixErr = <T as Num>::FromStrRadixErr

impl Num for u16[src]

impl Num for usize[src]

impl Num for i32[src]

impl Num for isize[src]

impl Num for u64[src]

impl Num for u8[src]

impl Num for u128[src]

impl Num for i8[src]

impl Num for i128[src]

impl Num for u32[src]

impl Num for i64[src]

impl Num for f32[src]

type FromStrRadixErr = ParseFloatError

impl Num for i16[src]

impl Num for f64[src]

type FromStrRadixErr = ParseFloatError

impl<T> Num for Complex<T> where
    T: Clone + Num
[src]

type FromStrRadixErr = ParseComplexError<<T as Num>::FromStrRadixErr>

fn from_str_radix(
    s: &str,
    radix: u32
) -> Result<Complex<T>, <Complex<T> as Num>::FromStrRadixErr>
[src]

Parses a +/- bi; ai +/- b; a; or bi where a and b are of type T

impl<T> Num for Ratio<T> where
    T: Clone + Integer
[src]

type FromStrRadixErr = ParseRatioError

fn from_str_radix(s: &str, radix: u32) -> Result<Ratio<T>, ParseRatioError>[src]

Parses numer/denom where the numbers are in base radix.

Loading content...

Implementors

Loading content...