b7689a7d60
The `InvalidFormat` variant was pretty bad: it didn't make it clear what exactly is wrong with the input string, especially since it was used when the denomination was missing. Not only was this unhelpful to the users who don't know they have to write the denomination when the amount was otherwise correct but it was also attributed to a problem with the amount rather than a problem with denomination. To fix this the variant is replaced by `MissingDigitsError`, `MissingError` and `InvalidCharError` - all the cases `InvalidFormat` was originally used in. `InvalidCharError` is effectively the same as the existing variant but it was made into a separate error to enable special casing `.` and make extensions possible. Further this opportunity was used to add a special case for `-` as well. `MissingDigitsError` currently contains special casing for empty string and a string only containing minus sign. It's currently unclear if it's useful so this change makes this distinction private and only makes it affect error messages. As opposed to the previous two variants, `MissingDenominationError` was added to `ParseError`. The struct is currenly empty and may be extended in the future with e.g. span information. |
||
---|---|---|
.. | ||
amount.rs | ||
lib.rs |