pub struct Roman(_);
Expand description
A Roman number
Stores the value internally a u32
Implementations§
source§impl Roman
impl Roman
sourcepub fn from<T: Into<u32>>(val: T) -> Result<Self>
pub fn from<T: Into<u32>>(val: T) -> Result<Self>
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
sourcepub fn from_unchecked<T: Into<u32>>(val: T) -> Self
pub fn from_unchecked<T: Into<u32>>(val: T) -> Self
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
sourcepub fn to_lowercase(self) -> String
pub fn to_lowercase(self) -> String
Returns lowercase string representation of the Roman numeral
sourcepub fn to_uppercase(self) -> String
pub fn to_uppercase(self) -> String
Returns uppercase string representation of the Roman numeral
Methods from Deref<Target = u32>§
Trait Implementations§
source§impl AsRef<u32> for Roman
impl AsRef<u32> for Roman
Support dereferencing to u32
Examples
let sept: Roman = Roman::from(7u32).unwrap();
let r: &u32 = &sept;
assert_eq!(&7, r);
source§impl FromStr for Roman
impl FromStr for Roman
source§impl Ord for Roman
impl Ord for Roman
source§impl PartialOrd<Roman> for Roman
impl PartialOrd<Roman> for Roman
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more