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.
This commit is contained in:
parent
274e7a4e49
commit
9ba32f306a
|
@ -113,13 +113,7 @@ impl cmp::Ord for Version {
|
||||||
(0, _) => false,
|
(0, _) => false,
|
||||||
(_, 0) => true,
|
(_, 0) => true,
|
||||||
(_, _) => self.pre < other.pre
|
(_, _) => self.pre < other.pre
|
||||||
})) ||
|
}))
|
||||||
|
|
||||||
(self.major == other.major &&
|
|
||||||
self.minor == other.minor &&
|
|
||||||
self.patch == other.patch &&
|
|
||||||
self.pre == other.pre &&
|
|
||||||
self.build < other.build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -377,15 +371,12 @@ fn test_spec_order() {
|
||||||
|
|
||||||
let vs = ["1.0.0-alpha",
|
let vs = ["1.0.0-alpha",
|
||||||
"1.0.0-alpha.1",
|
"1.0.0-alpha.1",
|
||||||
|
"1.0.0-alpha.beta",
|
||||||
|
"1.0.0-beta",
|
||||||
"1.0.0-beta.2",
|
"1.0.0-beta.2",
|
||||||
"1.0.0-beta.11",
|
"1.0.0-beta.11",
|
||||||
"1.0.0-rc.1",
|
"1.0.0-rc.1",
|
||||||
"1.0.0-rc.1+build.1",
|
"1.0.0"];
|
||||||
"1.0.0",
|
|
||||||
"1.0.0+0.3.7",
|
|
||||||
"1.3.7+build",
|
|
||||||
"1.3.7+build.2.b8f12d7",
|
|
||||||
"1.3.7+build.11.e0f985a"];
|
|
||||||
let mut i = 1;
|
let mut i = 1;
|
||||||
while i < vs.len() {
|
while i < vs.len() {
|
||||||
let a = parse(vs[i-1]).get();
|
let a = parse(vs[i-1]).get();
|
||||||
|
|
Loading…
Reference in New Issue