[−][src]Struct xvii::Roman
A Roman numeral.
This struct stores the value of a numeral as an NonZeroU16
but provides
for Roman-style formatting.
Implementations
impl Roman
[src]
pub fn new(n: u16) -> Result<Roman>
[src]
Creates a Roman
value based on a u16
.
This function will return None
if the value supplied is outside the
acceptable range of 1..=4999
, because numbers outside that range
cannot be appropriately formatted using the seven standard numerals.
pub fn to_uppercase(self) -> String
[src]
Formats a Roman
value as an uppercase Roman numeral.
Examples
use xvii::Roman; assert_eq!(Roman::new(42).unwrap().to_uppercase(), "XLII");
pub fn to_lowercase(self) -> String
[src]
Formats a Roman
value as a lowercase Roman numeral.
Examples
use xvii::Roman; assert_eq!(Roman::new(42).unwrap().to_lowercase(), "xlii");
pub const fn format(&self, style: Style) -> RomanFormatter
[src]
Returns a RomanFormatter
which lazily formats a self
value as a lowercase or uppercase Roman numeral depending of style
.
Examples
use xvii::{Roman, Style}; let value = Roman::new(12).unwrap(); assert_eq!(format!("{}", value.format(Style::Upper)), "XII"); assert_eq!(value.format(Style::Lower).to_string(), "xii"); // `format!("{}")` and `.to_string()` are the same thing
pub const fn value(self) -> u16
[src]
Returns value of this Roman
numeral.
Examples
let roman = xvii::Roman::new(42).unwrap(); assert_eq!(roman.value(), 42);
pub const fn into_inner(self) -> NonZeroU16
[src]
Returns the inner value.
Examples
let roman = xvii::Roman::new(42).unwrap(); assert_eq!(roman.into_inner(), std::num::NonZeroU16::new(42).unwrap());
Trait Implementations
impl Clone for Roman
[src]
impl Copy for Roman
[src]
impl Debug for Roman
[src]
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>
[src]
impl Hash for Roman
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Roman
[src]
fn cmp(&self, other: &Roman) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Roman> for Roman
[src]
impl PartialOrd<Roman> for Roman
[src]
fn partial_cmp(&self, other: &Roman) -> Option<Ordering>
[src]
fn lt(&self, other: &Roman) -> bool
[src]
fn le(&self, other: &Roman) -> bool
[src]
fn gt(&self, other: &Roman) -> bool
[src]
fn ge(&self, other: &Roman) -> bool
[src]
impl StructuralEq for Roman
[src]
impl StructuralPartialEq for Roman
[src]
Auto Trait Implementations
impl RefUnwindSafe for Roman
impl Send for Roman
impl Sync for Roman
impl Unpin for Roman
impl UnwindSafe for Roman
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,