Closed charliermarsh closed 2 weeks ago
Doesn't from_range_bounds
require two Version
? Like if v1
and v2
are Version
, Range::from_range_bounds(v1..v2)
?
It takes anything that implements RangeBounds. Here is the link to the docs: https://pubgrub-rs.github.io/pubgrub/pubgrub/range/struct.Range.html#method.from_range_bounds
And since it auto implemented for a pair of bounds I think you can direcly put a pair of bounds there: https://doc.rust-lang.org/nightly/core/ops/trait.RangeBounds.html#impl-RangeBounds%3CT%3E-for-(Bound%3CT%3E,+Bound%3CT%3E)
Thanks, I totally missed that!
In our use case, we pass in two RequiresPythonBound
that impl Into<Bound<Version>>
. The trick that i missed is that we need to eagerly convert into bounds, the Into<V>
only applies to the version, not the type with the bound, and specify the target of the conversion:
Range::from_range_bounds::<(Bound<Version>, Bound<Version>), _>((
value.0.into(),
value.1.into(),
))
Got it, apologies. Skill issue!
Thanks for the clarification.
@konstin, is there a better way for the generics on the fn? I'd be open to resuturing to make it EZer to use.
In uv, I have two
Bound<Version>
that I need to turn into aRange
. I ended up doing this semi-manually here. It would be nice to have a public constructor, if appropriate.