1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::semver;
use std::cmp::Ordering;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Release {
version: semver::Version,
}
impl Release {
pub fn new_stable(version: semver::Version) -> Self {
Self { version }
}
pub fn is_minor(&self) -> bool {
self.version.major != 0 && self.version.patch == 0 && self.version.build.is_empty()
}
pub fn is_patch(&self) -> bool {
self.version.patch != 0 && self.version.build.is_empty()
}
pub fn version(&self) -> &semver::Version {
&self.version
}
}
impl PartialOrd for Release {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Release {
fn cmp(&self, other: &Self) -> Ordering {
other.version().cmp(self.version())
}
}