From 6afad4dceb9b9badcb6fc5de588c842d1170aa14 Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Sun, 15 Oct 2023 14:08:27 +0200 Subject: [PATCH] Even more lints --- ctru-rs/examples/camera-image.rs | 4 ++-- ctru-rs/examples/title-info.rs | 12 +++++------- ctru-rs/src/services/romfs.rs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index ecf9f65..30938ce 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -140,8 +140,8 @@ fn rotate_image_to_screen(src: &[u8], framebuf: *mut u8, width: usize, height: u unsafe { // We'll work with pointers since the framebuffer is a raw pointer regardless. // The offsets are completely safe as long as the width and height are correct. - let pixel_pointer = framebuf.offset(draw_index as isize); - pixel_pointer.copy_from(src.as_ptr().offset(read_index as isize), 2); + let pixel_pointer = framebuf.add(draw_index); + pixel_pointer.copy_from(src.as_ptr().add(read_index), 2); } } } diff --git a/ctru-rs/examples/title-info.rs b/ctru-rs/examples/title-info.rs index d2898ac..b3b3f8e 100644 --- a/ctru-rs/examples/title-info.rs +++ b/ctru-rs/examples/title-info.rs @@ -58,19 +58,17 @@ fn main() { if hid.keys_down().intersects(KeyPad::DOWN) { if offset + 1 < cur_list.len() { - offset = offset + 1; - refresh = true; - } - } else if hid.keys_down().intersects(KeyPad::UP) { - if offset > 0 { - offset = offset - 1; + offset += 1; refresh = true; } + } else if hid.keys_down().intersects(KeyPad::UP) && offset > 0 { + offset -= 1; + refresh = true; } // Render the title list via a scrollable text UI. if refresh { - let mut selected_title = cur_list.iter().skip(offset).next().unwrap(); + let mut selected_title = cur_list.iter().nth(offset).unwrap(); // Clear the top screen and write title IDs to it. top_screen.select(); diff --git a/ctru-rs/src/services/romfs.rs b/ctru-rs/src/services/romfs.rs index 572aea6..1202f6d 100644 --- a/ctru-rs/src/services/romfs.rs +++ b/ctru-rs/src/services/romfs.rs @@ -87,7 +87,7 @@ mod tests { fn romfs_lock() { let romfs = RomFS::new().unwrap(); - let _value = *ROMFS_ACTIVE.try_lock().unwrap(); + *ROMFS_ACTIVE.try_lock().unwrap(); drop(romfs); }