pubgrub-rs / pubgrub

PubGrub version solving algorithm implemented in Rust
https://pubgrub-rs.github.io/pubgrub/pubgrub/
Mozilla Public License 2.0
337 stars 29 forks source link

Add `Range::is_empty()` and `Range::bounds()` #188

Closed konstin closed 3 months ago

konstin commented 3 months ago

We use Range::is_empty() for special casing the empty version range in error messages:

https://github.com/astral-sh/uv/blob/8d721830db8ad75b8b7ef38edc0e346696c52e3d/crates/uv-resolver/src/pubgrub/report.rs#L553

https://github.com/astral-sh/uv/blob/8d721830db8ad75b8b7ef38edc0e346696c52e3d/crates/uv-resolver/src/pubgrub/report.rs#L565

We use Range::bounds() to check for prerelease bounds and hint the user at our prerelease rules:

https://github.com/astral-sh/uv/blob/8d721830db8ad75b8b7ef38edc0e346696c52e3d/crates/uv-resolver/src/pubgrub/report.rs#L360

Upstream port of https://github.com/astral-sh/pubgrub/pull/16

Eh2406 commented 3 months ago

Range::bounds can be built on Range::iter, and it seems like a somewhat niche use case.

Range::is_empty is == Range::empty(), but might be clearer.

konstin commented 3 months ago

Good point, i've split off Range::is_empty() (https://github.com/pubgrub-rs/pubgrub/pull/189) and removed our Range::bounds() usage (https://github.com/astral-sh/uv/pull/2363)

Closing in favor of #189