improve ergonomics of integer, float, color and boolean formats slightly #13
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.
I find it quite annoying to keep building the home descriptions and one
of the more annoying things I find is describing properties. This change
improves the situation slightly by making it quite a bit more
straightforward to describe common integer, float and boolean formats.
In particular now instead of having to write out the entire
HomePropertyFormat::SomeType(SomeType { ... }),IntegerRange,FloatRange,BooleanFormatetc can be passed in as an argument directly. Forintegers and floats a further ergonomics are achieved by allowing another
common case (range without step) to be provided by using Rust's
built-in ranges.
For color format it might make sense to explore making it a bitfield
rather than a vector of enums. Among other things it would enforce that
the same colour does not appear twice. But even if that's done in the
future these From implementations would still be implementable just
fine, so they seemed fine to add.
The only caveat is that this likely has a negative impact on diagnostics.