Function forest_filecoin::cli::humantoken::parse::parse
source · pub fn parse(input: &str) -> Result<TokenAmount>
Expand description
Parse token amounts as floats with SI prefixed-units.
fn assert_attos(input: &str, attos: u64) {
let expected = TokenAmount::from_atto(attos);
let actual = parse(input).unwrap();
assert_eq!(expected, actual);
}
assert_attos("1a", 1);
assert_attos("1aFIL", 1);
assert_attos("1 femtoFIL", 1000);
assert_attos("1.1 f", 1100);
assert_attos("1.0e3 attofil", 1000);
§Known bugs
1efil
will not parse as an exa (10^18
), because we’ll try and parse it as a exponent in the float. Instead use1 efil
.