From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/clap_builder/src/util/any_value.rs | 15 +++++++++++++++ vendor/clap_builder/src/util/color.rs | 17 ++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'vendor/clap_builder/src/util') diff --git a/vendor/clap_builder/src/util/any_value.rs b/vendor/clap_builder/src/util/any_value.rs index dc7a3e953..6f1e3665e 100644 --- a/vendor/clap_builder/src/util/any_value.rs +++ b/vendor/clap_builder/src/util/any_value.rs @@ -69,6 +69,12 @@ impl PartialOrd for AnyValueId { } } +impl PartialEq for AnyValueId { + fn eq(&self, other: &std::any::TypeId) -> bool { + self.type_id == *other + } +} + impl Ord for AnyValueId { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.type_id.cmp(&other.type_id) @@ -109,4 +115,13 @@ mod test { assert_eq!(format!("{:?}", AnyValue::new(5)), "AnyValue { inner: i32 }"); } + + #[test] + fn eq_to_type_id() { + use super::*; + + let any_value_id = AnyValueId::of::(); + let type_id = std::any::TypeId::of::(); + assert_eq!(any_value_id, type_id); + } } diff --git a/vendor/clap_builder/src/util/color.rs b/vendor/clap_builder/src/util/color.rs index 7a0e837e7..d13a6df9e 100644 --- a/vendor/clap_builder/src/util/color.rs +++ b/vendor/clap_builder/src/util/color.rs @@ -64,6 +64,15 @@ pub enum ColorChoice { Never, } +impl ColorChoice { + /// Report all `possible_values` + pub fn possible_values() -> impl Iterator { + Self::value_variants() + .iter() + .filter_map(ValueEnum::to_possible_value) + } +} + impl Default for ColorChoice { fn default() -> Self { Self::Auto @@ -99,11 +108,9 @@ impl ValueEnum for ColorChoice { fn to_possible_value(&self) -> Option { Some(match self { - Self::Auto => { - PossibleValue::new("auto").help("Use colored output if writing to a terminal/TTY") - } - Self::Always => PossibleValue::new("always").help("Always use colored output"), - Self::Never => PossibleValue::new("never").help("Never use colored output"), + Self::Auto => PossibleValue::new("auto"), + Self::Always => PossibleValue::new("always"), + Self::Never => PossibleValue::new("never"), }) } } -- cgit v1.2.3