Skip to main content

parse_money

Function parse_money 

pub fn parse_money(text: &str) -> Option<u64>
Expand description

The millionths of the currency an amount a person typed names: 5, 0.50, 12.5 or $5, read the way money writes them.

None where the text names no amount, so the caller says what it wanted instead of taking a guess.

use tilo_ui::format::parse_money;
assert_eq!(parse_money("5"), Some(5_000_000));
assert_eq!(parse_money("0.50"), Some(500_000));
assert_eq!(parse_money("twelve"), None);