Skip to content

Commit 3549dc5

Browse files
authored
feat: add Range::is_empty() (pubgrub-rs#189)
We use `Range::is_empty()` for special casing the empty version range in error messages. This mirrors std, which has `is_empty` methods on all of its collections: https://doc.rust-lang.org/nightly/std/?search=is_empty Example usages: 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
1 parent d272713 commit 3549dc5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/range.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ impl<V> Range<V> {
119119
segments: SmallVec::one((Included(v1.into()), Excluded(v2.into()))),
120120
}
121121
}
122+
123+
/// Whether the set is empty, i.e. it has not ranges
124+
pub fn is_empty(&self) -> bool {
125+
self.segments.is_empty()
126+
}
122127
}
123128

124129
impl<V: Clone> Range<V> {

0 commit comments

Comments
 (0)