Skip to content

Commit e317999

Browse files
committed
address further lints in Windows-specific code
1 parent 2ea7c79 commit e317999

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

crates/prettytty/src/sys/windows.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::ffi::c_void;
1+
use core::ffi::c_void;
22
use std::fs::OpenOptions;
33
use std::io::{stderr, stdin, stdout, Error, ErrorKind, IsTerminal, Read, Result, Write};
44
use std::os::windows::io::{AsRawHandle, OwnedHandle};
5-
use std::ptr::{from_mut, null};
5+
use core::ptr::{from_mut, null};
66

77
use windows_sys::Win32::Foundation;
88
use windows_sys::Win32::Globalization;
@@ -29,16 +29,16 @@ enum RawConnectionHandle {
2929

3030
impl RawConnectionHandle {
3131
fn input(&self) -> RawHandle {
32-
match self {
33-
Self::Owned(input, _) => input.as_raw_handle(),
34-
Self::StdIo(input, _) => *input,
32+
match *self {
33+
Self::Owned(ref input, _) => input.as_raw_handle(),
34+
Self::StdIo(ref input, _) => *input,
3535
}
3636
}
3737

3838
fn output(&self) -> RawHandle {
39-
match self {
40-
Self::Owned(_, output) => output.as_raw_handle(),
41-
Self::StdIo(_, output) => *output,
39+
match *self {
40+
Self::Owned(_, ref output) => output.as_raw_handle(),
41+
Self::StdIo(_, ref output) => *output,
4242
}
4343
}
4444
}
@@ -48,6 +48,7 @@ impl RawConnectionHandle {
4848
// `Sync`](https://github.com/rust-lang/rust/blob/8e37e151835d96d6a7415e93e6876561485a3354/library/std/src/os/windows/io/handle.rs#L111),
4949
// for wrapped handles, too. Also, access to raw input is gated by a mutex.
5050
unsafe impl Send for RawConnectionHandle {}
51+
// SAFETY: See previous comment.
5152
unsafe impl Sync for RawConnectionHandle {}
5253

5354
/// A connection to a terminal device.
@@ -128,16 +129,16 @@ enum ModeGroup {
128129

129130
impl ModeGroup {
130131
pub fn all() -> impl core::iter::Iterator<Item = ModeGroup> {
131-
core::iter::successors(Some(Self::Input), |n| {
132-
Some(match n {
132+
core::iter::successors(Some(Self::Input), |g| {
133+
Some(match *g {
133134
Self::Input => Self::Output,
134135
Self::Output => return None,
135136
})
136137
})
137138
}
138139

139140
pub fn name(&self) -> &'static str {
140-
match self {
141+
match *self {
141142
Self::Input => "input_modes",
142143
Self::Output => "output_modes",
143144
}
@@ -350,7 +351,7 @@ impl Read for RawInput {
350351
unsafe {
351352
Console::ReadConsoleA(
352353
self.handle,
353-
buf.as_mut_ptr() as *mut c_void,
354+
buf.as_mut_ptr().cast::<c_void>(),
354355
buf.len() as u32,
355356
from_mut(&mut did_read),
356357
null(),

0 commit comments

Comments
 (0)