[WIP] Apply number formatting when using FluentNumberOptions #377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request aims to fill a gap found in the code regarding number formatting.
According to the code, 5 different format options are allowed regarding a number's length, considering rear and trailing zeroes when needed. These options are listed in the struct
FluentNumberOptions
.However, I can't figure out what is the expected difference between
FluentNumberOptions.maximum_significant_digits
andFluentNumberOptions.maximum_fraction_digits
; and betweenFluentNumberOptions.minimum_fraction_digits
andFluentNumberOptions.minimum_significant_digits
. I'll consider those redundant, and I won't implement any specific formatting unless someone tells me what's the difference.The current implementation:
https://github.com/projectfluent/fluent-rs/blob/f2033ce8340e09000ad9efccd6215b3fa5c23496/fluent-bundle/src/types/number.rs#L148C1-L165C2
Only considers the option
FluentNumberOptions.minimum_fraction_digits
, thus all the other options are simply ignored when provided. This was already reported by #368.I'd like to work on a proposal for the implementation of such missing logic. I've added a few unit tests that show what kind of formatting shall be expected when using the options. So the idea is to implement the code that make those test to pass.
Please, let me know if I'm missing something.
Notes for the reviewers: I added Rstest as a dev-dependency, if that is not acceptable, I'll rewrite the tests that I pushed.
Closes #368