Skip to content

Commit d422676

Browse files
z0w0graydon
authored andcommitted
---
yaml --- r: 46296 b: refs/heads/auto c: 321e3c4 h: refs/heads/master v: v3
1 parent 345b747 commit d422676

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: f18ae8ce7e2764b3d6f9b3c22c31163e55cac98a
17+
refs/heads/auto: 321e3c490906fed6ed1d46a7cbd2d2f9a42c9a53

branches/auto/src/libcore/semver.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use uint;
1717
use str;
1818
use to_str::ToStr;
1919
use char;
20+
use cmp;
2021

2122
pub struct Version {
2223
major: uint,
@@ -37,6 +38,61 @@ impl Version: ToStr {
3738
}
3839
}
3940

41+
impl Version: cmp::Ord {
42+
#[inline(always)]
43+
pure fn lt(&self, other: &Version) -> bool {
44+
self.major < other.major ||
45+
self.minor < other.minor ||
46+
self.patch < other.patch ||
47+
(match self.tag {
48+
Some(stag) => match other.tag {
49+
Some(otag) => stag < otag,
50+
None => true
51+
},
52+
None => false
53+
})
54+
}
55+
#[inline(always)]
56+
pure fn le(&self, other: &Version) -> bool {
57+
self.major <= other.major ||
58+
self.minor <= other.minor ||
59+
self.patch <= other.patch ||
60+
(match self.tag {
61+
Some(stag) => match other.tag {
62+
Some(otag) => stag <= otag,
63+
None => true
64+
},
65+
None => false
66+
})
67+
}
68+
#[inline(always)]
69+
pure fn gt(&self, other: &Version) -> bool {
70+
self.major > other.major ||
71+
self.minor > other.minor ||
72+
self.patch > other.patch ||
73+
(match self.tag {
74+
Some(stag) => match other.tag {
75+
Some(otag) => stag > otag,
76+
None => false
77+
},
78+
None => true
79+
})
80+
}
81+
#[inline(always)]
82+
pure fn ge(&self, other: &Version) -> bool {
83+
self.major >= other.major ||
84+
self.minor >= other.minor ||
85+
self.patch >= other.patch ||
86+
(match self.tag {
87+
Some(stag) => match other.tag {
88+
Some(otag) => stag >= otag,
89+
None => false
90+
},
91+
None => true
92+
})
93+
}
94+
}
95+
4096
fn read_whitespace(rdr: io::Reader, ch: char) -> char {
4197
let mut nch = ch;
4298

0 commit comments

Comments
 (0)