diff --git a/src/atom/mod.rs b/src/atom/mod.rs index 97c57f7..d8cb543 100644 --- a/src/atom/mod.rs +++ b/src/atom/mod.rs @@ -293,7 +293,9 @@ impl Ord for VersionNumbers { loop { match (a.next(), b.next()) { - (Some(a), Some(b)) if a.get().starts_with("0") => { + (Some(a), Some(b)) + if a.get().starts_with("0") || b.get().starts_with("0") => + { let a = a.get().trim_end_matches("0"); let b = b.get().trim_end_matches("0"); @@ -765,4 +767,16 @@ mod test { assert_cmp_display!(a, b, Ordering::Less); } + + #[test] + fn test_version_cmp_where_b_has_leading_zeros() { + let a = Version::parser() + .parse_finished(InputIter::new("1.2")) + .unwrap(); + let b = Version::parser() + .parse_finished(InputIter::new("1.054")) + .unwrap(); + + assert_cmp_display!(a, b, Ordering::Greater); + } }