Make Decimal generic over Uint type #1066
Closed
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.
Just to give you an idea of what this could look like if we wanted to be DRYer.
The idea is that eventually to implement
Decimal<Uint256>
we would only need toimpl DecimalInnerType for Uint256
.The downside is I don't think
Decimal::one
orDecimal::zero
can be be constant functions anymore because of this: rust-lang/rust#54469It doesn't look like we can avoid a bunch of breaking changes here, so if we like this I'm thinking I'll wait for
1.0
and for now just create aDecimal256
that's pretty much a copy-paste ofDecimal
.