From 60e90b6c9d8bdae01821e1edc407d19ccf7040b8 Mon Sep 17 00:00:00 2001 From: silvanshade Date: Tue, 22 Aug 2023 11:39:02 -0600 Subject: [PATCH] Fix browser example --- crates/icrate/examples/browser.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/icrate/examples/browser.rs b/crates/icrate/examples/browser.rs index 3d932f527..939a34548 100644 --- a/crates/icrate/examples/browser.rs +++ b/crates/icrate/examples/browser.rs @@ -1,4 +1,6 @@ #![deny(unsafe_op_in_unsafe_fn)] +#![cfg_attr(not(target_os = "macos"), allow(unused))] +use std::ptr::NonNull; use icrate::{ ns_string, @@ -40,15 +42,16 @@ declare_class!( #[method(initWithTextField:andWebView:)] #[allow(non_snake_case)] unsafe fn __init_withTextField_andWebView( - self: &mut Self, + this: *mut Self, text_field: &NSTextField, web_view: &WKWebView, - ) -> Option<&mut Self> { - let this: Option<&mut Self> = msg_send![super(self), init]; - let this = this?; - Ivar::write(&mut this.text_field, text_field.retain()); - Ivar::write(&mut this.web_view, web_view.retain()); - Some(this) + ) -> Option> { + let this: Option<&mut Self> = msg_send![super(this), init]; + this.map(|this| { + Ivar::write(&mut this.text_field, text_field.retain()); + Ivar::write(&mut this.web_view, web_view.retain()); + NonNull::from(this) + }) } }