From ad05d1624b1d460297616a99b4e6fed2c38c7751 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 19 Sep 2022 09:05:44 -0500 Subject: [PATCH 1/2] fix(help: Be more precise on literal vs not --- src/builder/styled_str.rs | 32 ++++++++++++++++++++++++++++++++ src/output/help.rs | 26 ++++++++++++++------------ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/builder/styled_str.rs b/src/builder/styled_str.rs index 61aad469d1d..503bf333747 100644 --- a/src/builder/styled_str.rs +++ b/src/builder/styled_str.rs @@ -219,6 +219,24 @@ impl From<&'_ &'static str> for StyledStr { } } +impl PartialOrd for StyledStr { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for StyledStr { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.iter().map(cmp_key).cmp(other.iter().map(cmp_key)) + } +} + +fn cmp_key(c: (Option