mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-03 05:03:46 +00:00
Use from_range_bounds (#6879)
Not the most ergonomic api pubgrub has to offer, but better than rolling our own.
This commit is contained in:
parent
34435d7d9d
commit
00c98a82b0
1 changed files with 10 additions and 23 deletions
|
|
@ -414,29 +414,10 @@ impl Default for RequiresPythonRange {
|
||||||
|
|
||||||
impl From<RequiresPythonRange> for Range<Version> {
|
impl From<RequiresPythonRange> for Range<Version> {
|
||||||
fn from(value: RequiresPythonRange) -> Self {
|
fn from(value: RequiresPythonRange) -> Self {
|
||||||
match (value.0.as_ref(), value.1.as_ref()) {
|
Range::from_range_bounds::<(Bound<Version>, Bound<Version>), _>((
|
||||||
(Bound::Included(lower), Bound::Included(upper)) => {
|
value.0.into(),
|
||||||
Range::from_range_bounds(lower.clone()..=upper.clone())
|
value.1.into(),
|
||||||
}
|
))
|
||||||
(Bound::Included(lower), Bound::Excluded(upper)) => {
|
|
||||||
Range::from_range_bounds(lower.clone()..upper.clone())
|
|
||||||
}
|
|
||||||
(Bound::Excluded(lower), Bound::Included(upper)) => {
|
|
||||||
Range::strictly_higher_than(lower.clone())
|
|
||||||
.intersection(&Range::lower_than(upper.clone()))
|
|
||||||
}
|
|
||||||
(Bound::Excluded(lower), Bound::Excluded(upper)) => {
|
|
||||||
Range::strictly_higher_than(lower.clone())
|
|
||||||
.intersection(&Range::strictly_lower_than(upper.clone()))
|
|
||||||
}
|
|
||||||
(Bound::Unbounded, Bound::Unbounded) => Range::full(),
|
|
||||||
(Bound::Unbounded, Bound::Included(upper)) => Range::lower_than(upper.clone()),
|
|
||||||
(Bound::Unbounded, Bound::Excluded(upper)) => Range::strictly_lower_than(upper.clone()),
|
|
||||||
(Bound::Included(lower), Bound::Unbounded) => Range::higher_than(lower.clone()),
|
|
||||||
(Bound::Excluded(lower), Bound::Unbounded) => {
|
|
||||||
Range::strictly_higher_than(lower.clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,6 +451,12 @@ impl Deref for RequiresPythonBound {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<RequiresPythonBound> for Bound<Version> {
|
||||||
|
fn from(bound: RequiresPythonBound) -> Self {
|
||||||
|
bound.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialOrd for RequiresPythonBound {
|
impl PartialOrd for RequiresPythonBound {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue