1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//!
//! Conversion functions.
//!
use crate::Any;
pub use crate::generated::conv::*;
/// Parameter for ROMAN().
#[derive(Debug)]
pub enum RomanStyle {
/// Only subtract powers of 10, not L or V, and only if the next
/// number is not more than 10 times greater. A number
/// following the larger one shall be smaller than the
/// subtracted number. Also known as classic.
Classic,
/// Powers of 10, and L and V may be subtracted, only if the
/// next number is not more than 10 times greater. A number
/// following the larger one shall be smaller than the subtracted number.
SubLXV,
/// Powers of 10 and L, but not V, may be subtracted, also if
/// the next number is more than 10 times greater. A number
/// following the larger one shall be smaller than the subtracted number.
SubLX,
/// Powers of 10, and L and V may be subtracted, also if the
/// next number is more than 10 times greater. A number following the larger
/// one shall be smaller than the subtracted number.
SubAllLXV,
/// Produce the fewest Roman digits possible. Also known as
/// simplified.
Simplified,
}
impl Any for RomanStyle {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
RomanStyle::Classic => "0",
RomanStyle::SubLXV => "1",
RomanStyle::SubLX => "2",
RomanStyle::SubAllLXV => "3",
RomanStyle::Simplified => "4",
});
}
}