Skip to content
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

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

FlammeShadow
Copy link
Contributor

@FlammeShadow FlammeShadow force-pushed the array-view-impl-eq-compare branch from d0e9c93 to 98756f5 Compare December 17, 2024 14:17
@coveralls
Copy link
Collaborator

coveralls commented Dec 17, 2024

Pull Request Test Coverage Report for Build 4258

Details

  • 0 of 9 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 81.22%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/arrayview.mbt 0 9 0.0%
Totals Coverage Status
Change from base Build 4254: -0.1%
Covered Lines: 4541
Relevant Lines: 5591

💛 - Coveralls

Copy link
Contributor

@gmlewis gmlewis left a 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?

@FlammeShadow
Copy link
Contributor Author

FlammeShadow commented Dec 17, 2024

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 : )

@gmlewis
Copy link
Contributor

gmlewis commented Dec 17, 2024

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]) {
Copy link
Contributor

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 {
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use guard?

@hackwaly
Copy link
Contributor

hackwaly commented Dec 19, 2024

I see op_equal is using imperative style and compare is using functional style. I suggest that to make them use same style.

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.

@bobzhang bobzhang enabled auto-merge (rebase) December 20, 2024 13:26
@bobzhang bobzhang merged commit 7b8f620 into moonbitlang:main Dec 20, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants