[][src]Trait based::NumeralSystem

pub trait NumeralSystem<T> {
    fn decode(&self, rep: &str) -> Result<T, StrError>;
fn encode(&self, val: T) -> Result<String, TryFromIntError>; }

NumeralSystem provides conversions to and from representations in the given system.

Required methods

fn decode(&self, rep: &str) -> Result<T, StrError>

Given a NumeralSystem and a number's representation in that system, return the number.

Returns Err if this function encounters a character not in the system, or if an int to int conversion fails.

fn encode(&self, val: T) -> Result<String, TryFromIntError>

Given a NumeralSystem and a number, return the representation of that number in the system.

Returns Err if an int to int conversion fails.

This will interpret signed integers as if their bits represented their unsigned counterparts.

Loading content...

Implementors

impl NumeralSystem<i128> for Base[src]

impl NumeralSystem<i16> for Base[src]

impl NumeralSystem<i32> for Base[src]

impl NumeralSystem<i64> for Base[src]

impl NumeralSystem<i8> for Base[src]

impl NumeralSystem<isize> for Base[src]

impl NumeralSystem<u128> for Base[src]

impl NumeralSystem<u16> for Base[src]

fn encode(&self, val: u16) -> Result<String, TryFromIntError>[src]

Never produces Err.

impl NumeralSystem<u32> for Base[src]

impl NumeralSystem<u64> for Base[src]

impl NumeralSystem<u8> for Base[src]

fn encode(&self, val: u8) -> Result<String, TryFromIntError>[src]

Never produces Err.

impl NumeralSystem<usize> for Base[src]

fn encode(&self, val: usize) -> Result<String, TryFromIntError>[src]

Never produces Err.

Loading content...