@@ -17,6 +17,7 @@ use uint;
17
17
use str;
18
18
use to_str:: ToStr ;
19
19
use char;
20
+ use cmp;
20
21
21
22
pub struct Version {
22
23
major : uint ,
@@ -37,6 +38,61 @@ impl Version: ToStr {
37
38
}
38
39
}
39
40
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
+
40
96
fn read_whitespace ( rdr : io:: Reader , ch : char ) -> char {
41
97
let mut nch = ch;
42
98
0 commit comments