/// Implement a protocol for an external class. /// /// This creates a given protocol implementation with regards to the /// type-system. Useful on types created with [`extern_class!`], not use this /// on custom classes created with [`define_class!`], instead, implement the /// protocol within that macro. /// /// [`define_class!`]: crate::define_class! /// /// # Examples /// /// ``` /// # #[cfg(not_available)] /// use objc2_foundation::NSObjectProtocol; /// # use objc2::runtime::NSObjectProtocol; /// use objc2::runtime::NSObject; /// use objc2::{extern_class, extern_conformance}; /// /// extern_class!( /// #[unsafe(super(NSObject))] /// #[derive(PartialEq, Eq, Hash, Debug)] /// pub struct MyClass; /// ); /// /// // SAFETY: The class `MyClass` conforms to the `NSObject` protocol (since /// // its superclass `NSObject` does). /// extern_conformance!(unsafe impl NSObjectProtocol for MyClass {}); /// ``` /// /// See the [`extern_class!`] macro for more examples. /// /// [`extern_class!`]: crate::extern_class! #[doc(alias = "@interface")] #[macro_export]
macro_rules! extern_conformance {
(unsafeimpl $(<$($t:ident : $($bound:ident)? $(?$sized:ident)? $(+ $b:path)*),* $(,)?>)? $ty:ident for $protocol:ty {}) => { unsafeimpl $(<$($t : $($bound)? $(?$sized)? $(+ $b)*),*>)? $ty for $protocol { // TODO(breaking): Add private marker here.
}
};
}
#[cfg(test)] mod tests { usecrate::runtime::NSObject; usecrate::{extern_class, extern_protocol};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.