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

Various refactorings #411

Merged
merged 23 commits into from Mar 25, 2020
Merged

Various refactorings #411

merged 23 commits into from Mar 25, 2020

Conversation

@Mingun
Copy link
Contributor

Mingun commented Mar 15, 2020

Part of large changeset, which includes also #410. Aimed to improve ergonomics, fill gaps in the API and overall consistency.

@Mingun Mingun force-pushed the Mingun:point branch from da04e16 to f958586 Mar 15, 2020
Copy link
Collaborator

nical left a comment

There are some welcome additions in here like the extra operators, PartialOrd for min/max and removing the try! macro, which could land without semver breaking changes if you want to separate them in a separate PR.

src/point.rs Show resolved Hide resolved
src/point.rs Outdated Show resolved Hide resolved
src/point.rs Show resolved Hide resolved
src/point.rs Outdated Show resolved Hide resolved
@Mingun Mingun force-pushed the Mingun:point branch from f958586 to ee69dd4 Mar 21, 2020
@Mingun Mingun requested a review from nical Mar 21, 2020
@Mingun Mingun force-pushed the Mingun:point branch from ee69dd4 to eb8452f Mar 22, 2020
@Mingun
Copy link
Contributor Author

Mingun commented Mar 22, 2020

As the number of commits approaches an obscene large number, I decided to finish part of them in this PR. All but the last are completely backward compatible. The last changes the type requirements for the *Assign operators and technically is a breaking change. However, it is highly unlikely that it will break anything in user code, because I'm bet that Point types always instantiated with types where the implementation of ordinary and *Assign operators is the same.

This does not mean that I propose to make this change in the patch, but this change can raise the version to 0.21 without the danger of actually breaking the user code. Although, if you don't want to take risks, I can exclude it from this PR and include it in one of my next PR with such breaking changes.


Summary of changes:

  • Replace deprecated try!
  • Mostly unified usage of #[inline]
  • Implement min/max/clamp in terms of PartialOrd for all types
  • Increase test coverage for operators of Points
  • Implement *Assign counterparts for operators of Points
  • Implement Round/Floor/Ceil/Zero for Points
  • Add many examples as doctests to various methods
@nical nical changed the title Some refactoring for point.rs Various refactorings Mar 24, 2020
@nical
Copy link
Collaborator

nical commented Mar 24, 2020

Sorry for the delay. Please remove the *Assign operators for now. The change is not particularly important so even if it isn't likely to break much code, let's just bundle it with the other breaking changes since there are going to be some. The rest looks good at a glance.

@Mingun Mingun force-pushed the Mingun:point branch from eb8452f to 19c0e97 Mar 24, 2020
@Mingun
Copy link
Contributor Author

Mingun commented Mar 24, 2020

Done

@nical
Copy link
Collaborator

nical commented Mar 25, 2020

@Mingun thanks, there are a few build errors which should be straightforward to fix.

Mingun added 4 commits Mar 15, 2020
- Implement Point2D - Size2D operator
- Implement Point3D +- Size3D operators
- Implement -Point3D operator
- Implement *Assign counterparts for operators
@Mingun Mingun force-pushed the Mingun:point branch from 19c0e97 to 444db0c Mar 25, 2020
@Mingun
Copy link
Contributor Author

Mingun commented Mar 25, 2020

The costs of frequent rebases, although I thought I tested all commits for buildable :/. Now all commits buildable

@nical
Copy link
Collaborator

nical commented Mar 25, 2020

Thank you for your patience.

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Mar 25, 2020

📌 Commit 444db0c has been approved by nical

@bors-servo
Copy link
Contributor

bors-servo commented Mar 25, 2020

Testing commit 444db0c with merge 190adc0...

@bors-servo
Copy link
Contributor

bors-servo commented Mar 25, 2020

☀️ Test successful - checks-travis
Approved by: nical
Pushing 190adc0 to master...

@bors-servo bors-servo merged commit 190adc0 into servo:master Mar 25, 2020
2 checks passed
2 checks passed
Travis CI - Pull Request Build Passed
Details
homu Test successful
Details
@Mingun Mingun deleted the Mingun:point branch Mar 25, 2020
bors-servo added a commit that referenced this pull request Mar 30, 2020
Some refactoring for size.rs

Part of large changeset, which includes also #410 and #411. Aimed to improve ergonomics, fill gaps in the API and overall consistency.
bors-servo added a commit that referenced this pull request Apr 5, 2020
Some refactoring, *Assign operators and box transform methods for Translations

As a continuation of [our discourse](#411 (comment)) about by value vs by reference: added translation methods for Boxes takes its by reference, but as [godbolt](https://rust.godbolt.org/z/Kgqdjd) shows, even without forced `#[inline]` directive compiler smart enough to inline such small function and the code the same in both cases. Therefore, I'm still in favour of taking everything by value in methods that almost only change unit. For now I'm, however, use reference as in surrounding code.
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.