Skip to content

Commit

Permalink
fix clippy warnings for ios
Browse files Browse the repository at this point in the history
- Warnings related to unsafe code has not been touched.
- The number of warnings has been reduced from 9 to 2 + 7 errors (denied lints).

- simplified manual range contains.
- simplified unneded explicit returns.
- simplified destructuring with match to if let.
  • Loading branch information
joseluis authored and not-fl3 committed Feb 7, 2025
1 parent 589b19b commit ec99dab
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/native/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ enum Message {
unsafe impl Send for Message {}

thread_local! {
static MESSAGES_TX: RefCell<Option<mpsc::Sender<Message>>> = RefCell::new(None);
static MESSAGES_TX: RefCell<Option<mpsc::Sender<Message>>> = const { RefCell::new(None) };
}

impl MainThreadState {
fn process_request(&mut self, request: crate::native::Request) {
use crate::native::Request::*;

match request {
ScheduleUpdate => {
self.update_requested = true;
}
_ => {}
if let ScheduleUpdate = request {
self.update_requested = true;
}
}
}
Expand Down Expand Up @@ -275,7 +272,7 @@ pub fn define_glk_or_mtk_view(superclass: &Class) -> *const Class {
}

decl.add_ivar::<*mut c_void>("display_ptr");
return decl.register();
decl.register()
}

unsafe fn get_proc_address(name: *const u8) -> Option<unsafe extern "C" fn()> {
Expand Down Expand Up @@ -371,7 +368,7 @@ pub fn define_glk_or_mtk_view_dlg(superclass: &Class) -> *const Class {
}

decl.add_ivar::<*mut c_void>("display_ptr");
return decl.register();
decl.register()
}

// metal or opengl view and the objects required to collect all the window events
Expand Down Expand Up @@ -691,8 +688,7 @@ pub fn define_app_delegate() -> *const Class {
application_will_resign_active as extern "C" fn(&Object, Sel, ObjcId),
);
}

return decl.register();
decl.register()
}

fn define_textfield_dlg() -> *const Class {
Expand All @@ -719,7 +715,7 @@ fn define_textfield_dlg() -> *const Class {
let c: u16 = msg_send![string, characterAtIndex: i];

match c {
c if c >= 32 && (c < 0xD800 || c > 0xDFFF) => {
c if c >= 32 && !(0xD800..=0xDFFF).contains(&c) => {
send_message(Message::Character {
character: c as u32,
})
Expand Down Expand Up @@ -778,7 +774,7 @@ fn define_textfield_dlg() -> *const Class {
);
}
decl.add_ivar::<*mut c_void>("display_ptr");
return decl.register();
decl.register()
}

pub fn log(message: &str) {
Expand Down Expand Up @@ -825,6 +821,7 @@ pub fn load_file<F: Fn(crate::fs::Response) + 'static>(path: &str, on_loaded: F)

// this is the way to pass argument to UiApplicationMain
// this static will be used exactly once, to .take() the "run" arguments
#[allow(clippy::type_complexity)]
static mut RUN_ARGS: Option<(Box<dyn FnOnce() -> Box<dyn EventHandler>>, Conf)> = None;

pub unsafe fn run<F>(conf: Conf, f: F)
Expand Down

0 comments on commit ec99dab

Please sign in to comment.