pub unsafe trait IvarType {
type Type: InnerIvarType;
const NAME: &'static str;
}Expand description
Helper trait for defining instance variables.
This should be implemented for an empty marker type, which can then be
used within Ivar to refer to the instance variable.
Safety
Really, Ivar should be marked as unsafe, but since we can’t do that
we’ll mark this trait as unsafe instead. See Ivar for safety
requirements.
Examples
Create an instance variable myCustomIvar with type i32.
use objc2::declare::IvarType;
// Helper type
struct MyCustomIvar;
unsafe impl IvarType for MyCustomIvar {
type Type = i32;
const NAME: &'static str = "myCustomIvar";
}
// `Ivar<MyCustomIvar>` can now be usedRequired Associated Types§
sourcetype Type: InnerIvarType
type Type: InnerIvarType
The type of the instance variable.