shoulda_core/
shoulda_of_type.rs

1use std::any::{type_name, Any, TypeId};
2
3pub trait ShouldaOfType {
4    fn should_type_of<I: Any + 'static>(&self) -> bool;
5    fn should_name() -> &'static str;
6}
7
8impl<T> ShouldaOfType for T
9where
10    T: AsRef<dyn Any>,
11{
12    fn should_type_of<I: Any + 'static>(&self) -> bool {
13        self.as_ref().type_id().eq(&TypeId::of::<I>())
14    }
15
16    fn should_name() -> &'static str {
17        type_name::<T>()
18    }
19}