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 @@ @@ -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() { @@ -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() { @@ -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.");
}

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

@ -1,11 +1,8 @@ @@ -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() {

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

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

22
ctru-rs/src/gfx.rs

@ -46,12 +46,10 @@ pub trait Screen { @@ -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 { @@ -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<TopScreen>,
pub bottom_screen: RefCell<BottomScreen>,
_private: (),
}
impl Gfx {
@ -88,9 +86,8 @@ 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 { @@ -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),
}
}
}

Loading…
Cancel
Save