Skip to content

Commit

Permalink
more clippy fixes (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored Jul 21, 2024
1 parent 480a373 commit 702eea4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
//! ```no_run
//! use std::io::prelude::*;
//!
//! fn main() {
//! let mut t = term::stdout().unwrap();
//! let mut t = term::stdout().unwrap();
//!
//! t.fg(term::color::GREEN).unwrap();
//! write!(t, "hello, ").unwrap();
//! t.fg(term::color::GREEN).unwrap();
//! write!(t, "hello, ").unwrap();
//!
//! t.fg(term::color::RED).unwrap();
//! writeln!(t, "world!").unwrap();
//! t.fg(term::color::RED).unwrap();
//! writeln!(t, "world!").unwrap();
//!
//! t.reset().unwrap();
//! }
//! t.reset().unwrap();
//! ```
//!
//! [ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code
Expand Down
4 changes: 2 additions & 2 deletions src/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl TermInfo {
Ok(TermInfo {
names: vec![name.to_owned()],
bools: HashMap::new(),
numbers: numbers,
strings: strings,
numbers,
strings,
})
} else {
Err(crate::Error::TerminfoEntryNotFound)
Expand Down
21 changes: 11 additions & 10 deletions src/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ unsafe fn set_flag(handle: HANDLE, flag: CONSOLE_MODE) -> io::Result<()> {
if SetConsoleMode(handle, curr_mode | flag) == 0 {
return Err(io::Error::last_os_error());
}
return Ok(());

Ok(())
}

/// Check if console supports ansi codes (should succeed on Windows 10)
Expand Down Expand Up @@ -311,14 +312,14 @@ impl<T: Write + Send> Terminal for WinConsole<T> {
}

fn supports_attr(&self, attr: Attr) -> bool {
match attr {
matches!(
attr,
Attr::ForegroundColor(_)
| Attr::BackgroundColor(_)
| Attr::Standout(_)
| Attr::Reverse
| Attr::Secure => true,
_ => false,
}
| Attr::BackgroundColor(_)
| Attr::Standout(_)
| Attr::Reverse
| Attr::Secure
)
}

fn reset(&mut self) -> Result<()> {
Expand Down Expand Up @@ -408,11 +409,11 @@ impl<T: Write + Send> Terminal for WinConsole<T> {
}
}

fn get_ref<'a>(&'a self) -> &'a T {
fn get_ref(&self) -> &T {
&self.buf
}

fn get_mut<'a>(&'a mut self) -> &'a mut T {
fn get_mut(&mut self) -> &mut T {
&mut self.buf
}

Expand Down

0 comments on commit 702eea4

Please sign in to comment.