From 37507741c4882124a94a79c5ccaac97a03034b2d Mon Sep 17 00:00:00 2001 From: Dillon Shaffer Date: Mon, 1 May 2023 08:40:00 -0600 Subject: [PATCH] impl Eq for clap_builder::util::AnyValueId --- clap_builder/src/util/any_value.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); + } }