Browse Source

Fixed clippy suggestions

pull/22/head
Andrea Ciliberti 3 years ago
parent
commit
366db9e046
  1. 8
      ctru-rs/examples/gfx-wide-mode.rs
  2. 3
      ctru-rs/examples/hello-world.rs
  3. 1
      ctru-rs/examples/network-sockets.rs
  4. 22
      ctru-rs/src/gfx.rs

8
ctru-rs/examples/gfx-wide-mode.rs

@ -1,5 +1,3 @@
extern crate ctru;
use ctru::console::Console; use ctru::console::Console;
use ctru::services::hid::KeyPad; use ctru::services::hid::KeyPad;
use ctru::services::{Apt, Hid}; use ctru::services::{Apt, Hid};
@ -10,7 +8,7 @@ fn main() {
let apt = Apt::init().unwrap(); let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap(); let hid = Hid::init().unwrap();
let gfx = Gfx::default(); 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."); println!("Press A to enable/disable wide screen mode.");
@ -22,12 +20,12 @@ fn main() {
} }
if hid.keys_down().contains(KeyPad::KEY_A) { if hid.keys_down().contains(KeyPad::KEY_A) {
drop(_console); drop(console);
let wide_mode = gfx.top_screen.borrow().get_wide_mode(); let wide_mode = gfx.top_screen.borrow().get_wide_mode();
gfx.top_screen.borrow_mut().set_wide_mode(!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."); println!("Press A to enable/disable wide screen mode.");
} }

3
ctru-rs/examples/hello-world.rs

@ -1,11 +1,8 @@
extern crate ctru;
use ctru::console::Console; use ctru::console::Console;
use ctru::gfx::Gfx; use ctru::gfx::Gfx;
use ctru::services::apt::Apt; use ctru::services::apt::Apt;
use ctru::services::hid::{Hid, KeyPad}; use ctru::services::hid::{Hid, KeyPad};
extern crate ferris_says;
use std::io::BufWriter; use std::io::BufWriter;
fn main() { fn main() {

1
ctru-rs/examples/network-sockets.rs

@ -1,4 +1,3 @@
extern crate ctru;
use ctru::console::Console; use ctru::console::Console;
use ctru::gfx::Gfx; use ctru::gfx::Gfx;
use ctru::services::apt::Apt; use ctru::services::apt::Apt;

22
ctru-rs/src/gfx.rs

@ -46,12 +46,10 @@ pub trait Screen {
} }
} }
pub struct TopScreen { #[non_exhaustive]
_private: (), pub struct TopScreen;
} #[non_exhaustive]
pub struct BottomScreen { pub struct BottomScreen;
_private: (),
}
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
/// Side of top screen framebuffer /// Side of top screen framebuffer
@ -68,10 +66,10 @@ pub enum Side {
/// provides helper functions and utilities for software rendering. /// provides helper functions and utilities for software rendering.
/// ///
/// The service exits when this struct is dropped. /// The service exits when this struct is dropped.
#[non_exhaustive]
pub struct Gfx { pub struct Gfx {
pub top_screen: RefCell<TopScreen>, pub top_screen: RefCell<TopScreen>,
pub bottom_screen: RefCell<BottomScreen>, pub bottom_screen: RefCell<BottomScreen>,
_private: (),
} }
impl Gfx { impl Gfx {
@ -88,9 +86,8 @@ impl Gfx {
ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), use_vram_buffers); ctru_sys::gfxInit(top_fb_fmt.into(), bottom_fb_fmt.into(), use_vram_buffers);
} }
Gfx { Gfx {
top_screen: RefCell::new(TopScreen { _private: () }), top_screen: RefCell::new(TopScreen),
bottom_screen: RefCell::new(BottomScreen { _private: () }), bottom_screen: RefCell::new(BottomScreen),
_private: (),
} }
} }
@ -169,9 +166,8 @@ impl Default for Gfx {
fn default() -> Self { fn default() -> Self {
unsafe { ctru_sys::gfxInitDefault() }; unsafe { ctru_sys::gfxInitDefault() };
Gfx { Gfx {
top_screen: RefCell::new(TopScreen { _private: () }), top_screen: RefCell::new(TopScreen),
bottom_screen: RefCell::new(BottomScreen { _private: () }), bottom_screen: RefCell::new(BottomScreen),
_private: (),
} }
} }
} }

Loading…
Cancel
Save