From c69c81a502c115885a551bb400bb9dc2d4b2045f Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Thu, 12 Mar 2020 12:55:27 -0500 Subject: [PATCH] Fixed clippy warnings --- src/writers/graphics_640x480x16.rs | 9 +++++---- src/writers/text_40x25.rs | 9 ++++----- src/writers/text_40x50.rs | 9 ++++----- src/writers/text_80x25.rs | 9 ++++----- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/writers/graphics_640x480x16.rs b/src/writers/graphics_640x480x16.rs index ab47b41..a9a1d02 100644 --- a/src/writers/graphics_640x480x16.rs +++ b/src/writers/graphics_640x480x16.rs @@ -7,7 +7,7 @@ use spinning_top::SpinlockGuard; const WIDTH: usize = 640; const HEIGHT: usize = 480; -static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3]; +static PLANES: &[Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3]; /// A basic interface for interacting with vga graphics mode 640x480x16 /// @@ -23,6 +23,7 @@ static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, /// graphics_mode.set_mode(); /// graphics_mode.clear_screen(); /// ``` +#[derive(Default)] pub struct Graphics640x480x16; impl Graphics640x480x16 { @@ -47,7 +48,7 @@ impl Graphics640x480x16 { assert!(x < WIDTH, "x >= {}", WIDTH); assert!(y < HEIGHT, "y >= {}", HEIGHT); let (mut vga, frame_buffer) = self.get_frame_buffer(); - let offset = (x / 8 + (WIDTH / 8) * y) as isize; + let offset = x / 8 + (WIDTH / 8) * y; // Store the current value for masking. let x = x & 7; @@ -56,14 +57,14 @@ impl Graphics640x480x16 { for plane in PLANES { vga.set_plane(*plane); - let current_value = unsafe { frame_buffer.offset(offset).read_volatile() }; + let current_value = unsafe { frame_buffer.add(offset).read_volatile() }; let new_value = if plane_mask & color as u8 != 0 { current_value | mask } else { current_value & !mask }; unsafe { - frame_buffer.offset(offset).write_volatile(new_value); + frame_buffer.add(offset).write_volatile(new_value); } plane_mask <<= 1; } diff --git a/src/writers/text_40x25.rs b/src/writers/text_40x25.rs index c800fde..0eebb85 100644 --- a/src/writers/text_40x25.rs +++ b/src/writers/text_40x25.rs @@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter { /// text_mode.set_mode(); /// text_mode.clear_screen(); /// ``` +#[derive(Default)] pub struct Text40x25; impl Text40x25 { @@ -43,9 +44,7 @@ impl Text40x25 { let (_vga, frame_buffer) = self.get_frame_buffer(); for i in 0..SCREEN_SIZE { unsafe { - frame_buffer - .offset(i as isize) - .write_volatile(BLANK_CHARACTER); + frame_buffer.add(i).write_volatile(BLANK_CHARACTER); } } } @@ -57,10 +56,10 @@ impl Text40x25 { assert!(x < WIDTH, "x >= {}", WIDTH); assert!(y < HEIGHT, "y >= {}", HEIGHT); let (_vga, frame_buffer) = self.get_frame_buffer(); - let offset = (WIDTH * y + x) as isize; + let offset = WIDTH * y + x; unsafe { frame_buffer - .offset(offset) + .add(offset) .write_volatile(ScreenCharacter { character, color }); } } diff --git a/src/writers/text_40x50.rs b/src/writers/text_40x50.rs index 797b51b..3b252d6 100644 --- a/src/writers/text_40x50.rs +++ b/src/writers/text_40x50.rs @@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter { /// text_mode.set_mode(); /// text_mode.clear_screen(); /// ``` +#[derive(Default)] pub struct Text40x50; impl Text40x50 { @@ -43,9 +44,7 @@ impl Text40x50 { let (_vga, frame_buffer) = self.get_frame_buffer(); for i in 0..SCREEN_SIZE { unsafe { - frame_buffer - .offset(i as isize) - .write_volatile(BLANK_CHARACTER); + frame_buffer.add(i).write_volatile(BLANK_CHARACTER); } } } @@ -57,10 +56,10 @@ impl Text40x50 { assert!(x < WIDTH, "x >= {}", WIDTH); assert!(y < HEIGHT, "y >= {}", HEIGHT); let (_vga, frame_buffer) = self.get_frame_buffer(); - let offset = (WIDTH * y + x) as isize; + let offset = WIDTH * y + x; unsafe { frame_buffer - .offset(offset) + .add(offset) .write_volatile(ScreenCharacter { character, color }); } } diff --git a/src/writers/text_80x25.rs b/src/writers/text_80x25.rs index fc1e1da..d60e035 100644 --- a/src/writers/text_80x25.rs +++ b/src/writers/text_80x25.rs @@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter { /// text_mode.set_mode(); /// text_mode.clear_screen(); /// ``` +#[derive(Default)] pub struct Text80x25; impl Text80x25 { @@ -43,9 +44,7 @@ impl Text80x25 { let (_vga, frame_buffer) = self.get_frame_buffer(); for i in 0..SCREEN_SIZE { unsafe { - frame_buffer - .offset(i as isize) - .write_volatile(BLANK_CHARACTER); + frame_buffer.add(i).write_volatile(BLANK_CHARACTER); } } } @@ -57,10 +56,10 @@ impl Text80x25 { assert!(x < WIDTH, "x >= {}", WIDTH); assert!(y < HEIGHT, "y >= {}", HEIGHT); let (_vga, frame_buffer) = self.get_frame_buffer(); - let offset = (WIDTH * y + x) as isize; + let offset = WIDTH * y + x; unsafe { frame_buffer - .offset(offset) + .add(offset) .write_volatile(ScreenCharacter { character, color }); } }