1
Fork 0
romantic/README.md

54 lines
1.8 KiB
Markdown
Raw Normal View History

2022-09-26 11:08:50 +00:00
# Romantic 🏛
2022-04-10 14:11:14 +00:00
2022-09-26 11:08:50 +00:00
> **Roman numeral library for Rust.**
2022-04-10 14:11:14 +00:00
## API
2022-09-26 11:08:50 +00:00
For full documentation see [docs.rs](https://docs.rs/romantic).
2022-04-10 14:11:14 +00:00
## Examples
Using the default Roman numeral system.
```rust
use romantic::Roman;
let roman = Roman::default();
assert_eq!(roman.to_string(2022).unwrap(), "MMXXII");
assert_eq!(roman.from_str::<i32>("MMXXII").unwrap(), 2022);
2022-09-26 11:08:50 +00:00
// The default Roman numeral system has a maximum of 3999.
2022-04-10 14:11:14 +00:00
assert!(roman.to_string(4000).is_err());
```
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']);
assert_eq!(custom.to_string(6).unwrap(), "BA");
assert_eq!(custom.from_str::<i32>("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.to_string(9).is_err());
```
## Development
With [Nix flakes](https://nixos.wiki/wiki/Flakes) and [direnv](https://direnv.net/) installed and enabled, all the required dependencies are automatically loaded from [`shell.nix`](./shell.nix). Then [cargo-make](https://sagiegurari.github.io/cargo-make/) can be used to build, deploy and lint the code. The available tasks are all described in the [`Makefile.toml`](Makefile.toml) configuration.
2022-09-26 11:08:50 +00:00
## Feedback
2022-04-10 14:11:14 +00:00
2022-09-26 11:08:50 +00:00
Found a problem or want to request a new feature? Email [helllo@holllo.org](mailto:helllo@holllo.org) and I'll see what I can do for you.
## License
2022-04-10 14:11:14 +00:00
2022-09-26 11:08:50 +00:00
Distributed under the [Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html) and [MIT](https://spdx.org/licenses/MIT.html) licenses, see [LICENSE-Apache](https://git.bauke.xyz/Holllo/romantic/src/branch/main/LICENSE-Apache) and [LICENSE-MIT](https://git.bauke.xyz/Holllo/romantic/src/branch/main/LICENSE-MIT) for more information.