Skip to content

Commit 1947269

Browse files
authored
Enable OrdEq on U128 (#6048)
## Description OrdEq was disabled there two years ago because it didn't work, it works now. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
1 parent 7ee627c commit 1947269

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sway-lib-std/src/u128.sw

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ impl core::ops::Ord for U128 {
152152
}
153153
}
154154

155-
// TODO this doesn't work?
156-
// impl core::ops::OrdEq for U128 {
157-
// }
155+
impl core::ops::OrdEq for U128 {}
156+
158157
impl u64 {
159158
/// Performs addition between two `u64` values, returning a `U128`.
160159
///
@@ -629,8 +628,7 @@ impl core::ops::Divide for U128 {
629628
quotient <<= 1;
630629
remainder <<= 1;
631630
remainder.lower = remainder.lower | (self >> i).lower & 1;
632-
// TODO use >= once OrdEq can be implemented.
633-
if remainder > divisor || remainder == divisor {
631+
if remainder >= divisor {
634632
remainder -= divisor;
635633
quotient.lower = quotient.lower | 1;
636634
}

0 commit comments

Comments
 (0)