Crates.io | roman-literals |
lib.rs | roman-literals |
version | 0.2.1 |
source | src |
created_at | 2022-08-26 21:44:17.426305 |
updated_at | 2022-08-28 18:33:42.231186 |
description | Write integer literals using Roman numerals |
homepage | https://github.com/j-tai/roman-literals |
repository | https://github.com/j-tai/roman-literals |
max_upload_size | |
id | 653068 |
size | 149,712 |
roman-literals
roman-literals
provides an easy way to write integer literals using Roman
numerals.
roman!
] macroType aliases like [iXXXII
] are provided to replace primitive types like
[i32
].
Using the [roman!
] macro, the type of the literal is automatically
inferred, with [iXXXII
] being the default. The macro also supports
negative numbers; see [roman!
] for more details.
Constants are also provided, such as III_uXXXII
. These constants are all
suffixed with their type. See the [consts
] module for more details.
use roman_literals::*; // roman! macro and type aliases
let forty_two: uXXXII = roman!(XLII);
assert_eq!(forty_two, 42);
let negative_3999: iXVI = roman!(-MMMCMXCIX);
assert_eq!(negative_3999, -3999);
use roman_literals::consts::*; // to get the constants
let negative_300 = -CCC_iLXIV; // i64
assert_eq!(negative_300, -300);
Why not?