Closed brycefisher closed 6 years ago
Thanks for your patience and the detailed PR, I'm finally getting around to this :)
It's been quite a while since I've given this repository any attention or maintenance, but hopefully it's treating you well. I added one more test case I could think of; the rest seems adequate to me.
Thanks again!
What It Does
Allows strings like
"(12.10)"
to be parsed as negativeCurrency
values.Why?
Because in some financial/accounting applications, currency is treated this way. Also this crate is the best Rust library on crates.io for parsing currency strings into meaningful types.
Limitations
I tried to follow the pattern I've inferred from the source code -- specifically to try not to fail on oddly formatted data instead of returning parsing errors. This means that there are tons of strings which will be successfully parsed by
Currency::from_str
which would look wrong to a human. See the new test cases for all the examples I could think of. Here's the most zany examples I could think of:")this is a Currency struct with 0 bigint value inside"
->Currency { symbol: None, biginit::from(0) }
"(((($1"
->Currency { symbol: Some('$'), biginit::from(-100) }
I'm not sure I feel great about this approach, and I'm very happy to change the implementation to add some strictness / sanity check :-)