Skip to content

Commit

Permalink
Apply suggestions from clippy 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Dec 16, 2024
1 parent de2f15a commit 09be64b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> Iterator for Matches<'a> {
}
}

impl<'a> FusedIterator for Matches<'a> {}
impl FusedIterator for Matches<'_> {}

fn find_ansi_code_exclusive(it: &mut Peekable<CharIndices>) -> Option<(usize, usize)> {
'outer: loop {
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'a> Iterator for AnsiCodeIterator<'a> {
}
}

impl<'a> FusedIterator for AnsiCodeIterator<'a> {}
impl FusedIterator for AnsiCodeIterator<'_> {}

#[cfg(test)]
mod tests {
Expand All @@ -284,7 +284,7 @@ mod tests {
.unwrap();
}

impl<'a, 'b> PartialEq<Match<'a>> for regex::Match<'b> {
impl<'a> PartialEq<Match<'a>> for regex::Match<'_> {
fn eq(&self, other: &Match<'a>) -> bool {
self.start() == other.start && self.end() == other.end
}
Expand Down
6 changes: 3 additions & 3 deletions src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub enum TermFamily {
#[derive(Debug, Clone)]
pub struct TermFeatures<'a>(&'a Term);

impl<'a> TermFeatures<'a> {
impl TermFeatures<'_> {
/// Check if this is a real user attended terminal (`isatty`)
#[inline]
pub fn is_attended(&self) -> bool {
Expand Down Expand Up @@ -630,7 +630,7 @@ impl Write for Term {
}
}

impl<'a> Write for &'a Term {
impl Write for &Term {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
match self.inner.buffer {
Some(ref buffer) => buffer.lock().unwrap().write_all(buf),
Expand All @@ -650,7 +650,7 @@ impl Read for Term {
}
}

impl<'a> Read for &'a Term {
impl Read for &Term {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
io::stdin().read(buf)
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ impl<'a, 'b> Emoji<'a, 'b> {
}
}

impl<'a, 'b> fmt::Display for Emoji<'a, 'b> {
impl fmt::Display for Emoji<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if wants_emoji() {
write!(f, "{}", self.0)
Expand Down
17 changes: 9 additions & 8 deletions src/windows_term/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use windows_sys::Win32::System::Console::{

use crate::Term;

#[allow(clippy::upper_case_acronyms)]
type WORD = u16;

const FG_CYAN: WORD = FG_BLUE | FG_GREEN;
Expand Down Expand Up @@ -115,7 +116,7 @@ impl Console {
let info = screen_buffer_info(h)?;
let attr = TextAttributes::from_word(info.attributes());
Ok(Console {
kind: kind,
kind,
start_attr: attr,
cur_attr: attr,
})
Expand Down Expand Up @@ -185,7 +186,7 @@ struct TextAttributes {
}

impl TextAttributes {
fn to_word(&self) -> WORD {
fn to_word(self) -> WORD {
let mut w = 0;
w |= self.fg_color.to_fg();
w |= self.fg_intense.to_fg();
Expand Down Expand Up @@ -213,16 +214,16 @@ pub enum Intense {
}

impl Intense {
fn to_bg(&self) -> WORD {
fn to_bg(self) -> WORD {
self.to_fg() << 4
}

fn from_bg(word: WORD) -> Intense {
Intense::from_fg(word >> 4)
}

fn to_fg(&self) -> WORD {
match *self {
fn to_fg(self) -> WORD {
match self {
Intense::No => 0,
Intense::Yes => FG_INTENSITY,
}
Expand Down Expand Up @@ -252,16 +253,16 @@ pub enum Color {
}

impl Color {
fn to_bg(&self) -> WORD {
fn to_bg(self) -> WORD {
self.to_fg() << 4
}

fn from_bg(word: WORD) -> Color {
Color::from_fg(word >> 4)
}

fn to_fg(&self) -> WORD {
match *self {
fn to_fg(self) -> WORD {
match self {
Color::Black => 0,
Color::Blue => FG_BLUE,
Color::Green => FG_GREEN,
Expand Down
6 changes: 3 additions & 3 deletions src/windows_term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use windows_sys::Win32::System::Console::{
FillConsoleOutputAttribute, FillConsoleOutputCharacterA, GetConsoleCursorInfo, GetConsoleMode,
GetConsoleScreenBufferInfo, GetNumberOfConsoleInputEvents, GetStdHandle, ReadConsoleInputW,
SetConsoleCursorInfo, SetConsoleCursorPosition, SetConsoleMode, SetConsoleTitleW,
CONSOLE_CURSOR_INFO, CONSOLE_SCREEN_BUFFER_INFO, COORD, INPUT_RECORD, KEY_EVENT,
KEY_EVENT_RECORD, STD_ERROR_HANDLE, STD_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
CONSOLE_CURSOR_INFO, CONSOLE_SCREEN_BUFFER_INFO, COORD, INPUT_RECORD, INPUT_RECORD_0,
KEY_EVENT, KEY_EVENT_RECORD, STD_ERROR_HANDLE, STD_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
};
use windows_sys::Win32::UI::Input::KeyboardAndMouse::VIRTUAL_KEY;

Expand Down Expand Up @@ -490,7 +490,7 @@ fn read_key_event() -> io::Result<KEY_EVENT_RECORD> {
continue;
}

key_event = unsafe { mem::transmute(buffer.Event) };
key_event = unsafe { mem::transmute::<INPUT_RECORD_0, KEY_EVENT_RECORD>(buffer.Event) };

if key_event.bKeyDown == 0 {
// This is a key being released; ignore it.
Expand Down

0 comments on commit 09be64b

Please sign in to comment.