pub trait Has<Prop> {
type Val: Sized;
// Required method
fn get<P>(&self) -> Self::Val
where Constrain: TypeEq<Prop, P>;
}Expand description
Type-level properties. This trait can be used to associate marker types with properties of the implementating type.
§Examples
use type_eq::{Constrain, Has, TypeEq};
// marler type for the "name" property
struct Name;
struct Foo;
impl Has<Name> for Foo {
type Val = &'static str;
fn get<P>(&self) -> Self::Val
where
Constrain: TypeEq<Name, P>,
{
"Foo"
}
}
assert_eq!("Foo", Foo.get::<Name>());
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.