pubgrub-rs / pubgrub

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

feat: contains_many and simplify works with iter of V not just &V #179

Closed Eh2406 closed 5 months ago

Eh2406 commented 5 months ago

contains takes a &V, because if you haven't owned V (even behind the smart pointer Box/Arc/Cow) it is easy to add a &. So contains_many copied that interface and takes an iterator of Item = &V. Unfortunately, if you have an iterator of Item = V (or Item = Box/Arc/Cow of V) it is not straightforward to get a reference.

This came up in the context of semver-pubgrub, whose implementation of contains needs to ignore the BuildMetadata part of the semver version. I will be investigating if there are ways to work around this by expressing =x.y.z.pre as >=x.y.z.pre, <x.y.z.pre.0. But even if semver-pubgrub does not need this functionality it doesn't hurt to make contains_many more flexible.

Eh2406 commented 5 months ago

I rebased which required some intervention due to #183. So while I was looking at it I noticed that we had not made the symmetric change for simplify. So I added that as well. I will give some time for re-review due to the substantive changes.