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

Use Ranges::from_iter over Ranges::iter_mut #8825

Closed
wants to merge 12 commits into from

Conversation

konstin
Copy link
Member

@konstin konstin commented Nov 5, 2024

Use astral-sh/pubgrub#34 (pubgrub-rs/pubgrub#273) for safer ranges modification that can't break pubgrub invariants.

In the process, I removed the &mut references in favor of a direct immutable-to-immutable mapping.

The tests currently fail, i think it's because we're producing empty segments where Ranges expects them to be non-empty; See pubgrub-rs/pubgrub#273 for more discussion on invariants.

@zanieb
Copy link
Member

zanieb commented Nov 5, 2024

Should we change

let mut range = Range::empty();
// TODO(zanieb): We need to make sure this is performant, repeated unions like this do not
// seem efficient.
for version in versions {
range = range.union(&Range::singleton(version.clone()));
}
and
// Note this repeated-union construction is not particularly efficient, but there's not
// better API exposed by PubGrub. Since we're just generating an error message, it's
// probably okay, but we should investigate a better upstream API.
new_range = new_range.union(&Range::from_range_bounds((lower, upper)));
too?

@konstin
Copy link
Member Author

konstin commented Nov 5, 2024

Do those match the invariants from pubgrub-rs/pubgrub#273, or do those need Ranges:from_unsorted from pubgrub-rs/pubgrub#273?

@zanieb
Copy link
Member

zanieb commented Nov 5, 2024

I don't know! :)

@charliermarsh charliermarsh force-pushed the charlie/local branch 3 times, most recently from cb920e4 to 37e32e2 Compare November 6, 2024 03:19
Base automatically changed from charlie/local to tracking/050 November 6, 2024 03:26
@konstin konstin closed this Nov 6, 2024
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.

4 participants