Skip to content

Commit 3750774

Browse files
committed
impl Eq<std::any::TypeId> for clap_builder::util::AnyValueId
1 parent fa57ed3 commit 3750774

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clap_builder/src/util/any_value.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ impl PartialOrd for AnyValueId {
6969
}
7070
}
7171

72+
impl PartialEq<std::any::TypeId> for AnyValueId {
73+
fn eq(&self, other: &std::any::TypeId) -> bool {
74+
self.type_id == *other
75+
}
76+
}
77+
7278
impl Ord for AnyValueId {
7379
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
7480
self.type_id.cmp(&other.type_id)
@@ -109,4 +115,13 @@ mod test {
109115

110116
assert_eq!(format!("{:?}", AnyValue::new(5)), "AnyValue { inner: i32 }");
111117
}
118+
119+
#[test]
120+
fn eq_to_type_id() {
121+
use super::*;
122+
123+
let any_value_id = AnyValueId::of::<i32>();
124+
let type_id = std::any::TypeId::of::<i32>();
125+
assert_eq!(any_value_id, type_id);
126+
}
112127
}

0 commit comments

Comments
 (0)