3 个不稳定版本
0.2.1 | 2022年8月28日 |
---|---|
0.2.0 | 2022年8月28日 |
0.1.0 | 2022年8月26日 |
#276 in 值格式化
150KB
4.5K SLoC
roman-literals
roman-literals
提供了一种使用罗马数字编写整数字面量的简单方法。
功能
- 支持从 I 到 MMMCMXCIX(1 到 3999)的所有整数
- 使用
roman!
宏进行类型推断 - 零成本!
使用方法
示例
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);
为什么?
为什么不呢?