Trait num::Num [] [src]

pub trait Num: Zero<Output = Self> + One<Output = Self> + Add<Self> + Sub<Self, Output = Self> + Mul<Self> + Div<Self, Output = Self> + Rem<Self, Output = Self> + PartialEq<Self> {
    type FromStrRadixErr;
    fn from_str_radix(
        str: &str,
        radix: u32
    ) -> Result<Self, Self::FromStrRadixErr>; }

The base trait for numeric types

Associated Types

Required Methods

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());Run

Implementors