Skip to content

Commit 6ef3ae1

Browse files
z0w0graydon
authored andcommitted
---
yaml --- r: 47017 b: refs/heads/try c: 321e3c4 h: refs/heads/master i: 47015: 48cf742 v: v3
1 parent ce4bf15 commit 6ef3ae1

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: f18ae8ce7e2764b3d6f9b3c22c31163e55cac98a
5+
refs/heads/try: 321e3c490906fed6ed1d46a7cbd2d2f9a42c9a53
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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)