[][src]Struct septem::Roman

pub struct Roman(_);

A Roman number

Stores the value internally a u32

Implementations

impl Roman[src]

pub fn from<T: Into<u32>>(val: T) -> Result<Self>[src]

Creates a Roman numeral for any value that implements Into<u32>. Requires value to be greater than 0, and less than 4000.

Examples


let sept: Roman = Roman::from(7u32).unwrap();
assert_eq!("VII", sept.to_string());

Returns Roman , or an `septem::Error

pub fn from_unchecked<T: Into<u32>>(val: T) -> Self[src]

Creates a Roman numeral for any value that implements Into<u32>. Does not to any range checking, so can result in weird numerals.

Examples


let sept: Roman = Roman::from_unchecked(5032u32);
assert_eq!("MMMMMXXXII", sept.to_string());

Returns Roman

pub fn to_lowercase(self) -> String[src]

Returns lowercase string representation of the Roman numeral

pub fn to_uppercase(self) -> String[src]

Returns uppercase string representation of the Roman numeral

pub fn to_digits(self) -> Vec<Digit>[src]

Returns vector of digits representing the roman numeral

Methods from Deref<Target = u32>

pub const MIN: u321.43.0[src]

pub const MAX: u321.43.0[src]

pub const BITS: u32[src]

pub fn as_ne_bytes(&self) -> &[u8; 4][src]

🔬 This is a nightly-only experimental API. (num_as_ne_bytes)

Return the memory representation of this integer as a byte array in native byte order.

to_ne_bytes should be preferred over this whenever possible.

Examples

#![feature(num_as_ne_bytes)]
let num = 0x12345678u32;
let bytes = num.as_ne_bytes();
assert_eq!(
    bytes,
    if cfg!(target_endian = "big") {
        &[0x12, 0x34, 0x56, 0x78]
    } else {
        &[0x78, 0x56, 0x34, 0x12]
    }
);

Trait Implementations

impl AsRef<u32> for Roman[src]

Support dereferencing to u32

Examples


let sept: Roman = Roman::from(7u32).unwrap();
let r: &u32 = &sept;
assert_eq!(&7, r);

impl Clone for Roman[src]

impl Copy for Roman[src]

impl Debug for Roman[src]

impl Deref for Roman[src]

type Target = u32

The resulting type after dereferencing.

fn deref(&self) -> &u32[src]

Returns the integer representation of the Roman numeral

impl Display for Roman[src]

impl Eq for Roman[src]

impl FromStr for Roman[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Error>[src]

Creates a Roman numeral from a string representing the roman numerals

Examples


let sept: Roman = "VII".parse().unwrap();
assert_eq!(7, *sept);

Returns Roman , or an septem::Error

impl Ord for Roman[src]

impl PartialEq<Roman> for Roman[src]

impl PartialOrd<Roman> for Roman[src]

impl Send for Roman[src]

impl StructuralEq for Roman[src]

impl StructuralPartialEq for Roman[src]

impl Sync for Roman[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.