Skip to content

Commit dd025df

Browse files
Kaholazlpil
authored andcommitted
Allow convertions from Version and pubgrub::range::Range.
1 parent b567126 commit dd025df

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/version.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,19 @@ impl Range {
337337
}
338338
}
339339

340+
impl From<pubgrub::range::Range<Version>> for Range {
341+
fn from(range: pubgrub::range::Range<Version>) -> Self {
342+
let spec = range.to_string();
343+
Self { spec, range }
344+
}
345+
}
346+
347+
impl From<Version> for Range {
348+
fn from(version: Version) -> Self {
349+
pubgrub::range::Range::exact(version).into()
350+
}
351+
}
352+
340353
impl fmt::Debug for Range {
341354
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
342355
f.debug_tuple("Range").field(&self.spec).finish()

0 commit comments

Comments
 (0)