-
Notifications
You must be signed in to change notification settings - Fork 968
Closed
Milestone
Description
While indeed the derived
Ord
instance are not used, I guess I was doing something idiomatic here (not entirely my fault, the function has been in existence way before #3518):
Lines 283 to 306 in f88394c
/// Sorts [`ToolchainName`]s in the following order: /// 1. `stable`/`beta`/`nightly`-prefixed names, in this exact order. /// 2. `X.Y.Z-suffix` names, sorted by semver rules on `X.Y.Z`, then by `suffix`. /// 3. Other names, sorted alphanumerically. pub(crate) fn toolchain_sort(v: &mut [ToolchainName]) { v.sort_by_key(|name| { let s = name.to_string(); if s.starts_with("stable") { return (0, None, s); } if s.starts_with("beta") { return (1, None, s); } if s.starts_with("nightly") { return (2, None, s); } if let Some((ver_str, suffix)) = s.split_once('-') { if let Ok(ver) = semver::Version::parse(ver_str) { return (3, Some(ver), suffix.to_owned()); } } (4, None, s) }) }
How about making use of that to write an actual
Ord
instance?
Metadata
Metadata
Assignees
Labels
No labels