diff --git a/src/lib.rs b/src/lib.rs index ce70bf3..03e1c00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 diff --git a/src/terminfo/mod.rs b/src/terminfo/mod.rs index a8c414f..ed6875b 100644 --- a/src/terminfo/mod.rs +++ b/src/terminfo/mod.rs @@ -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) diff --git a/src/win.rs b/src/win.rs index d1be08f..64facb7 100644 --- a/src/win.rs +++ b/src/win.rs @@ -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) @@ -311,14 +312,14 @@ impl Terminal for WinConsole { } 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<()> { @@ -408,11 +409,11 @@ impl Terminal for WinConsole { } } - 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 }