Skip to content

Commit f945043

Browse files
committed
fix: clippy suggestions
1 parent 67b15f5 commit f945043

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

examples/coloring_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fn set_foreground_color() -> Result<()> {
4242

4343
// background intensity is a separate value in attrs,
4444
// wee need to check if this was applied to the current bg color.
45-
if (attrs & 0x0080 as u16) != 0 {
46-
color = color | 0x0080 as u16;
45+
if (attrs & 0x0080_u16) != 0 {
46+
color |= 0x0080_u16;
4747
}
4848

4949
// set the console text attribute to the new color value.

src/cfi.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt;
22
use std::mem::zeroed;
33

4-
use winapi::um::wincontypes::CONSOLE_FONT_INFO;
4+
use windows_sys::Win32::System::Console::CONSOLE_FONT_INFO;
55

66
use crate::Size;
77

@@ -40,3 +40,9 @@ impl FontInfo {
4040
self.0.nFont
4141
}
4242
}
43+
44+
impl Default for FontInfo {
45+
fn default() -> Self {
46+
Self::new()
47+
}
48+
}

src/console.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl Console {
213213
/// a u32.
214214
fn read_input(&self, buf: &mut [INPUT_RECORD]) -> Result<usize> {
215215
let mut num_records = 0;
216-
debug_assert!(buf.len() < std::u32::MAX as usize);
216+
debug_assert!(buf.len() < u32::MAX as usize);
217217

218218
result(unsafe {
219219
ReadConsoleInputW(

src/csbi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ impl ScreenBufferInfo {
7575
}
7676
}
7777

78+
impl Default for ScreenBufferInfo {
79+
fn default() -> Self {
80+
Self::new()
81+
}
82+
}
83+
7884
impl From<CONSOLE_SCREEN_BUFFER_INFO> for ScreenBufferInfo {
7985
fn from(csbi: CONSOLE_SCREEN_BUFFER_INFO) -> Self {
8086
ScreenBufferInfo(csbi)

src/screen_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use std::io::Result;
44
use std::mem::size_of;
55

6-
use windows_sys::Win32::Security::SECURITY_ATTRIBUTES;
76
use windows_sys::Win32::Storage::FileSystem::{FILE_SHARE_READ, FILE_SHARE_WRITE};
87
use windows_sys::Win32::System::Console::{
98
CreateConsoleScreenBuffer, GetConsoleScreenBufferInfo, SetConsoleActiveScreenBuffer,
109
SetConsoleScreenBufferSize, CONSOLE_TEXTMODE_BUFFER, COORD,
1110
};
1211
use windows_sys::Win32::System::SystemServices::{GENERIC_READ, GENERIC_WRITE};
12+
use windows_sys::Win32::{Security::SECURITY_ATTRIBUTES, System::Console::GetCurrentConsoleFont};
1313
pub const TRUE: ::windows_sys::Win32::Foundation::BOOL = 1;
1414

1515
use super::{handle_result, result, FontInfo, Handle, HandleType, ScreenBufferInfo};

src/structs/coord.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ impl From<Coord> for COORD {
3535
}
3636
}
3737

38-
impl Into<(u16, u16)> for Coord {
39-
fn into(self) -> (u16, u16) {
40-
(self.x as u16, self.y as u16)
38+
impl From<Coord> for (u16, u16) {
39+
fn from(val: Coord) -> Self {
40+
(val.x as u16, val.y as u16)
4141
}
4242
}

src/structs/size.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl From<COORD> for Size {
2424
}
2525
}
2626

27-
impl Into<(u16, u16)> for Size {
28-
fn into(self) -> (u16, u16) {
29-
(self.width as u16, self.height as u16)
27+
impl From<Size> for (u16, u16) {
28+
fn from(val: Size) -> Self {
29+
(val.width as u16, val.height as u16)
3030
}
3131
}

0 commit comments

Comments
 (0)