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

Introduce total_cmp on GeoNum to avoid unwraps #1134

Merged
merged 6 commits into from
Jan 10, 2024
Merged

Conversation

michaelkirk
Copy link
Member

@michaelkirk michaelkirk commented Jan 2, 2024

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

In particular the latest home crate used by bindgen, required by proj, needs rust-1.70+

Also updates CI containers to latest

In particular the latest `home` crate used by bindgen, required by proj, needs rust-1.70+

Also updates CI containers to latest
@michaelkirk michaelkirk force-pushed the mkirk/rust-msrv-1.70 branch 2 times, most recently from 5d5ff20 to ac35b65 Compare January 2, 2024 23:31
@urschrei
Copy link
Member

urschrei commented Jan 2, 2024

Is the TotalOrd trait requirement a result of the MSRV bump?

@urschrei
Copy link
Member

urschrei commented Jan 2, 2024

Ah, just read the commit message. It's due to a lint introduced in Rust 1.75

@@ -241,7 +241,7 @@ fn vwp_wrapper<T, const INITIAL_MIN: usize, const MIN_POINTS: usize>(
epsilon: &T,
) -> Vec<Vec<Coord<T>>>
where
T: CoordFloat + RTreeNum + HasKernel,
T: GeoFloat + RTreeNum,
Copy link
Member Author

@michaelkirk michaelkirk Jan 3, 2024

Choose a reason for hiding this comment

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

Without this change I get:

error[E0599]: no method named `intersects` found for struct `CachedEnvelope<geo_types::Line<T>>` in the current scope

This error was happening because the previous constraint, CoordFloat + HasKernel was enough to hit the impl GeoNum for T blanket impl. Since GeoFloat is basically CoordFloat + HasKernel it makes sense to just use GeoFloat to fix this and similar future problems if we add other traits.

This fixes a new lint introduced in rust 1.75

Fixes #1088
@michaelkirk michaelkirk force-pushed the mkirk/rust-msrv-1.70 branch from f73379c to 014ed5c Compare January 3, 2024 01:49
The previous approach worked, but then there was feedback that the trait
should maybe be "more complete" and implemented on additional types.

Really, I introduced the trait to solve a problem: we have some
undesirable unwraps in the codebase with some of our floating type
geometries. I didn't care to actually introduce a general-purpose TotalOrd
trait that was useful outside of that context.
There's so little you could do with HasKernel that isn't also a GeoNum.
I'm not sure there's value in having two traits.
@michaelkirk michaelkirk changed the title Bump MSRV to fix CI Introduce total_cmp on GeoNum to avoid unwraps Jan 4, 2024
@michaelkirk michaelkirk force-pushed the mkirk/rust-msrv-1.70 branch from 6b9ad93 to 9ea617b Compare January 4, 2024 01:53
@michaelkirk michaelkirk requested a review from rmanoka January 4, 2024 01:58
@michaelkirk michaelkirk force-pushed the mkirk/rust-msrv-1.70 branch from 9ea617b to dfdd025 Compare January 4, 2024 02:00
@michaelkirk
Copy link
Member Author

@rmanoka - did you want to weigh in on this? I've gotten a few positive responses so far so I'm going to go ahead and merge it in a couple days if I don't hear from you.

@rmanoka
Copy link
Contributor

rmanoka commented Jan 10, 2024

Looks good to me too! +1 for merge.

@michaelkirk michaelkirk added this pull request to the merge queue Jan 10, 2024
Merged via the queue into main with commit e0f4b6a Jan 10, 2024
@michaelkirk michaelkirk deleted the mkirk/rust-msrv-1.70 branch January 10, 2024 05:08
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