[−][src]Macro iron_oxide::handle
Provides an implementation of Drop
which implements lifetime-based releasing
on the implemented type's pointer to an Objective C object.
This implementation of Drop
decrements the reference count of the object which the
get_ptr
method returns. This ensures that the object to which the implementor points
lives only for the lifetime of the implementor.
Requirements
The ident passed into handle!
must be the correct local name of a struct or enum which
implements Object
.
Example
use iron_oxide::{ObjectPointer, handle, Object}; struct Wrapper(ObjectPointer); handle!(Wrapper); impl Object for Wrapper { unsafe fn from_ptr(ptr: ObjectPointer) -> Self where Self: Sized { Wrapper(ptr) } fn get_ptr(&self) -> ObjectPointer { self.0 } }