Skip to content

Commit 6a77125

Browse files
z0w0graydon
authored andcommitted
---
yaml --- r: 53141 b: refs/heads/dist-snap c: 321e3c4 h: refs/heads/master i: 53139: 54a60f8 v: v3
1 parent 6f43c95 commit 6a77125

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
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: f18ae8ce7e2764b3d6f9b3c22c31163e55cac98a
10+
refs/heads/dist-snap: 321e3c490906fed6ed1d46a7cbd2d2f9a42c9a53
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)