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

Implement abs for size and vector types. #232

Merged
merged 1 commit into from Nov 7, 2017
Merged

Implement abs for size and vector types. #232

merged 1 commit into from Nov 7, 2017

Conversation

@nical
Copy link
Collaborator

nical commented Nov 7, 2017

Fixes #231.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Nov 7, 2017

r? @kvark

it'd be nice to have a method for size that would clamp all negative components to zero, since that's the other common interpretation of negative sizes (depending on the context). I don't know how that method would be called.

@kvark
Copy link
Member

kvark commented Nov 7, 2017

Looks fine by me. Have you considered implementing Signed for TypedSize2D and friends instead of adding free-standing methods?

@nical
Copy link
Collaborator Author

nical commented Nov 7, 2017

I was on the edge and wasn't sure whether it would be controversial. I can definitely do it if you have a preference towards it. That means implementing:

    fn abs(&self) -> Self;
    fn abs_sub(&self, other: &Self) -> Self;
    fn signum(&self) -> Self;
    fn is_positive(&self) -> bool;
    fn is_negative(&self) -> bool;

I am not sure what the most sensible thing is for is_negative between:

  • returning true if all components are negative,
  • returning true if at least one component is negative.
@kvark
Copy link
Member

kvark commented Nov 7, 2017

Oh, I assumed at least some of those are not required to implement. Nevermind then :)
Also, it looks like the changes are non-breaking, which is good.
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2017

📌 Commit 5096fd4 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2017

Testing commit 5096fd4 with merge 22a5145...

bors-servo added a commit that referenced this pull request Nov 7, 2017
Implement abs for size and vector types.

Fixes #231.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/232)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing 22a5145 to master...

@bors-servo bors-servo merged commit 5096fd4 into servo:master Nov 7, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nical nical deleted the nical:abs branch Nov 7, 2017
@nical nical mentioned this pull request Nov 7, 2017
bors-servo added a commit that referenced this pull request Nov 7, 2017
Version 0.15.5.

Forgot to increment the version number in #232.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/233)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.