From 366db9e04617b364207d20b34151e702e358cb7c Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Sat, 22 Jan 2022 14:00:14 +0100 Subject: [PATCH] Fixed clippy suggestions --- ctru-rs/examples/gfx-wide-mode.rs | 8 +++----- ctru-rs/examples/hello-world.rs | 3 --- ctru-rs/examples/network-sockets.rs | 1 - ctru-rs/src/gfx.rs | 22 +++++++++------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ctru-rs/examples/gfx-wide-mode.rs b/ctru-rs/examples/gfx-wide-mode.rs index 633488c..fcf3fa9 100644 --- a/ctru-rs/examples/gfx-wide-mode.rs +++ b/ctru-rs/examples/gfx-wide-mode.rs @@ -1,5 +1,3 @@ -extern crate ctru; - use ctru::console::Console; use ctru::services::hid::KeyPad; use ctru::services::{Apt, Hid}; @@ -10,7 +8,7 @@ fn main() { let apt = Apt::init().unwrap(); let hid = Hid::init().unwrap(); let gfx = Gfx::default(); - let mut _console = Console::init(gfx.top_screen.borrow_mut()); + let mut console = Console::init(gfx.top_screen.borrow_mut()); println!("Press A to enable/disable wide screen mode."); @@ -22,12 +20,12 @@ fn main() { } if hid.keys_down().contains(KeyPad::KEY_A) { - drop(_console); + drop(console); let wide_mode = gfx.top_screen.borrow().get_wide_mode(); gfx.top_screen.borrow_mut().set_wide_mode(!wide_mode); - _console = Console::init(gfx.top_screen.borrow_mut()); + console = Console::init(gfx.top_screen.borrow_mut()); println!("Press A to enable/disable wide screen mode."); } diff --git a/ctru-rs/examples/hello-world.rs b/ctru-rs/examples/hello-world.rs index 57407a5..930549f 100644 --- a/ctru-rs/examples/hello-world.rs +++ b/ctru-rs/examples/hello-world.rs @@ -1,11 +1,8 @@ -extern crate ctru; use ctru::console::Console; use ctru::gfx::Gfx; use ctru::services::apt::Apt; use ctru::services::hid::{Hid, KeyPad}; -extern crate ferris_says; - use std::io::BufWriter; fn main() { diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index 6f434ee..84978e9 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -1,4 +1,3 @@ -extern crate ctru; use ctru::console::Console; use ctru::gfx::Gfx; use ctru::services::apt::Apt; diff --git a/ctru-rs/src/gfx.rs b/ctru-rs/src/gfx.rs index aec2572..1092640 100644 --- a/ctru-rs/src/gfx.rs +++ b/ctru-rs/src/gfx.rs @@ -46,12 +46,10 @@ pub trait Screen { } } -pub struct TopScreen { - _private: (), -} -pub struct BottomScreen { - _private: (), -} +#[non_exhaustive] +pub struct TopScreen; +#[non_exhaustive] +pub struct BottomScreen; #[derive(Copy, Clone, Debug)] /// Side of top screen framebuffer @@ -68,10 +66,10 @@ pub enum Side { /// provides helper functions and utilities for software rendering. /// /// The service exits when this struct is dropped. +#[non_exhaustive] pub struct Gfx { pub top_screen: RefCell, pub bottom_screen: RefCell, - _private: (), } impl Gfx { @@ -88,9 +86,8 @@ impl Gfx { ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), use_vram_buffers); } Gfx { - top_screen: RefCell::new(TopScreen { _private: () }), - bottom_screen: RefCell::new(BottomScreen { _private: () }), - _private: (), + top_screen: RefCell::new(TopScreen), + bottom_screen: RefCell::new(BottomScreen), } } @@ -169,9 +166,8 @@ impl Default for Gfx { fn default() -> Self { unsafe { ctru_sys::gfxInitDefault() }; Gfx { - top_screen: RefCell::new(TopScreen { _private: () }), - bottom_screen: RefCell::new(BottomScreen { _private: () }), - _private: (), + top_screen: RefCell::new(TopScreen), + bottom_screen: RefCell::new(BottomScreen), } } }