-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[move] Implement generic comparison method in move - move part (cmp::compare) #15245
Conversation
⏱️ 1h 3m total CI duration on this PR
🚨 1 job on the last run was significantly faster/slower than expected
|
686d2de
to
a85b7e7
Compare
3e9fb56
to
52eebf4
Compare
a85b7e7
to
2efd3d0
Compare
52eebf4
to
6d8744d
Compare
/// - enum's are compared first by their variant, and if equal - they are compared as structs are. | ||
native public(friend) fun compare<T>(first: &T, second: &T): Ordering; | ||
|
||
public fun is_eq(self: &Ordering): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just eq
, lt
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
primarily to align with Rust naming - https://doc.rust-lang.org/std/cmp/enum.Ordering.html
but secondly, eq soudns much more like a binary operator (i.e. a.eq(b)
), vs is_eq sounds like unary - compare(a, b).is_eq()
struct SomeStruct has drop { | ||
field_1: u64, | ||
field_2: u64, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline missing here
native public(friend) fun compare<T>(first: &T, second: &T): Ordering; | ||
|
||
public fun is_eq(self: &Ordering): bool { | ||
self is Ordering::Equal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have is_ne
/ne
? as well?
2efd3d0
to
81dbdb6
Compare
6d8744d
to
3c7a17d
Compare
81dbdb6
to
83e27b8
Compare
3c7a17d
to
7c84b5f
Compare
83e27b8
to
f72afc4
Compare
7c84b5f
to
0ea0a79
Compare
f72afc4
to
07bad73
Compare
0ea0a79
to
0ed1006
Compare
c5bf1b0
to
7a63894
Compare
5e9556a
to
7c1b9c7
Compare
7a63894
to
eb4b7a4
Compare
7c1b9c7
to
d6f7b1d
Compare
eb4b7a4
to
f8b9b81
Compare
ee38172
to
20d08b0
Compare
20d08b0
to
7093dad
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7093dad
to
b6298b6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
Separated out move part of the cmp::compare native call (first part is in the #14714), as it requires enums, and can only land after enums are enabled.
How Has This Been Tested?
Key Areas to Review
Type of Change
Which Components or Systems Does This Change Impact?
Checklist