Romantic 🏛

Roman numeral library for Rust.

API

For full documentation see docs.rs.

Examples

Using the default Roman numeral system.

```rust use romantic::Roman;

let roman = Roman::default();

asserteq!(roman.tostring(2022).unwrap(), "MMXXII"); asserteq!(roman.fromstr::("MMXXII").unwrap(), 2022);

// The default Roman numeral system has a maximum of 3999. assert!(roman.tostring(4000).iserr()); ```

Using your own custom character set.

```rust use romantic::Roman;

// The order of characters in the array determines their value. // Here, A equals 1 and B equals 5. let custom = Roman::new(&['A', 'B']);

asserteq!(custom.tostring(6).unwrap(), "BA"); asserteq!(custom.fromstr::("BA").unwrap(), 6);

// With only 2 characters, the maximum value you can get is 8 // (the equivalent of VIII). To increase the maximum range, use // more characters. assert!(custom.tostring(9).iserr()); ```

Feedback

Found a problem or want to request a new feature? Email helllo@holllo.org and I'll see what I can do for you.

License

Distributed under the Apache License 2.0 and MIT licenses, see LICENSE-Apache and LICENSE-MIT for more information.