Skip to content

Commit 9ba32f3

Browse files
committed
Update the ordering algorithm to semver 2.0.0.
Note that Version's `le` is not "less than or equal to" now, since `lt` ignores build metadata. I think the new ordering algorithm satisfies strict weak ordering which C++ STL requires, instead of strict total ordering.
1 parent 274e7a4 commit 9ba32f3

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/libextra/semver.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ impl cmp::Ord for Version {
113113
(0, _) => false,
114114
(_, 0) => true,
115115
(_, _) => self.pre < other.pre
116-
})) ||
117-
118-
(self.major == other.major &&
119-
self.minor == other.minor &&
120-
self.patch == other.patch &&
121-
self.pre == other.pre &&
122-
self.build < other.build)
116+
}))
123117
}
124118

125119
#[inline]
@@ -377,15 +371,12 @@ fn test_spec_order() {
377371
378372
let vs = ["1.0.0-alpha",
379373
"1.0.0-alpha.1",
374+
"1.0.0-alpha.beta",
375+
"1.0.0-beta",
380376
"1.0.0-beta.2",
381377
"1.0.0-beta.11",
382378
"1.0.0-rc.1",
383-
"1.0.0-rc.1+build.1",
384-
"1.0.0",
385-
"1.0.0+0.3.7",
386-
"1.3.7+build",
387-
"1.3.7+build.2.b8f12d7",
388-
"1.3.7+build.11.e0f985a"];
379+
"1.0.0"];
389380
let mut i = 1;
390381
while i < vs.len() {
391382
let a = parse(vs[i-1]).get();

0 commit comments

Comments
 (0)