diff --git a/clap_builder/src/util/any_value.rs b/clap_builder/src/util/any_value.rs index dc7a3e95394..6f1e3665e53 100644 --- a/clap_builder/src/util/any_value.rs +++ b/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); + } }