-
Notifications
You must be signed in to change notification settings - Fork 90
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
impl Eq/Compare traits for ArrayView #1337
impl Eq/Compare traits for ArrayView #1337
Conversation
FlammeShadow
commented
Dec 17, 2024
- missing Eq, Compare... traits impl for ArrayView #1291
d0e9c93
to
98756f5
Compare
Pull Request Test Coverage Report for Build 4258Details
💛 - Coveralls |
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.
Thank you, @FlammeShadow !
Maybe you could add a couple doc examples like you did for the other PR?
Oh, I thought their functions are obvious, so I didn't add doc and examples : ) |
I suppose they are, but pretty cool nevertheless. 😄 |
return false | ||
} | ||
for i in 0..<self.length() { | ||
if not(self[i] == other[i]) { |
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.
self[i] != other[i]
?
if not(self[i] == other[i]) { | ||
return false | ||
} | ||
} else { |
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.
avoid else
of for
as we are using imperative here. See return
in loop.
|
||
///| | ||
pub impl[T : Eq] Eq for ArrayView[T] with op_equal(self, other) -> Bool { | ||
if self.length() != other.length() { |
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.
use guard
?
I see I must admit that imperative style is more readable than functional style sometimes, but here seems they are equivalent. And you are free to choose one of these two style. |