Percentage
percentage
is a crate trying to make using percentages in a safer way and easier to debug.
Whenever you see a Percentage, you will know what is being calculated, instead of having to revise the code.
Example
// You only need to import the `Percentage` struct
use Percentage;
// Here we create the percentage to apply
let percent = from;
println!; // Will print '50'
// We can apply the percent to any number we want
assert_eq!;
println!; // Will print '50% of 30 is: 15'
// If you need to use floating points for the percent, you can use `from_decimal` instead
let percent = from_decimal;
assert_eq!;
println!; // Will print '50% of 30.0 is: 15.0'