Percentage Type with Decimal
A type to represent percentage with high precision thanks to rust_decimal
.
A percentage can perform addition, subtraction and multiplication.
use Percentage;
use Decimal;
let p1 = from;
let p2 = from;
let p3 = try_from.unwrap;
let p4 = from;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// note that a multiplication to integer type can lose precision
assert_eq!;
// multiplication on extremely small value with Decimal,
// that is not representable with float point
let small_value = from_str.unwrap;
assert_eq!;
Contributing
Contributions and feed back are welcome following Github workflow.
License
decimal_percentage
is provided under the MIT license. See LICENSE.