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

Remove some ApproxEq bounds #259

Merged
merged 4 commits into from Jan 13, 2018
Merged

Conversation

@pizzaiter
Copy link
Contributor

pizzaiter commented Jan 13, 2018

This PR removes ApproxEq bounds from several functions. In most cases the bound was unneeded, the major exception being normalize(). Here, I removed the divide by zero checks. Let me argue why this is reasonable.

  • The previous behavior was surprising. Similar crates (e.g. cgmath, nalgebra) do not make checks. (nalgebra has an additional try_normalize() that takes a min_norm argument.)
  • It was inconsistent with other similar functions in euclid that either do not make checks or return an Option. Also, the latter is only done for exact equality with zero and not approximate equality.
  • It caused a bug in one of my programs. 😄

This change is Reviewable

@nical
Copy link
Collaborator

nical commented Jan 13, 2018

Thanks a lot. I am 300% for the removal of the check in normalize. Could you bump the version as well, so that we can publish this right away?

@pizzaiter
Copy link
Contributor Author

pizzaiter commented Jan 13, 2018

Great! I bumped the version to 0.16.2.

@nical
Copy link
Collaborator

nical commented Jan 13, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2018

📌 Commit 2b819e8 has been approved by nical

@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2018

Testing commit 2b819e8 with merge 22cdd6d...

bors-servo added a commit that referenced this pull request Jan 13, 2018
Remove some ApproxEq bounds

This PR removes `ApproxEq` bounds from several functions. In most cases the bound was unneeded, the major exception being `normalize()`. Here, I removed the divide by zero checks. Let me argue why this is reasonable.

- The previous behavior was surprising. Similar crates (e.g. cgmath, nalgebra) do not make checks. (nalgebra has an additional `try_normalize()` that takes a `min_norm` argument.)
- It was inconsistent with other similar functions in euclid that either do not make checks or return an `Option`. Also, the latter is only done for exact equality with zero and not approximate equality.
- It caused a bug in one of my programs. 😄

<!-- 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/259)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2018

☀️ Test successful - status-travis
Approved by: nical
Pushing 22cdd6d to master...

@bors-servo bors-servo merged commit 2b819e8 into servo:master Jan 13, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@pizzaiter pizzaiter deleted the pizzaiter:remove-approxeq-bounds branch Jan 14, 2018
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.