summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder/src/util
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/clap_builder/src/util
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_builder/src/util')
-rw-r--r--vendor/clap_builder/src/util/any_value.rs15
-rw-r--r--vendor/clap_builder/src/util/color.rs17
2 files changed, 27 insertions, 5 deletions
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<std::any::TypeId> 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::<i32>();
+ let type_id = std::any::TypeId::of::<i32>();
+ 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<Item = PossibleValue> {
+ 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<PossibleValue> {
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"),
})
}
}