diff --git a/src/args.rs b/src/args.rs index 05c3529..a6541b9 100644 --- a/src/args.rs +++ b/src/args.rs @@ -7,9 +7,6 @@ use crate::{ }; use std::{error::Error, fmt, result::Result}; -#[cfg(not(test))] -use atty; - /// The error returned if something goes awry while parsing the /// command line arguments. #[derive(Debug)] diff --git a/src/gopher/type.rs b/src/gopher/type.rs index 11ccf53..4d486d3 100644 --- a/src/gopher/type.rs +++ b/src/gopher/type.rs @@ -37,10 +37,7 @@ impl Type { /// Text document? pub fn is_text(self) -> bool { - match self { - Type::Text | Type::Xml => true, - _ => false, - } + matches!(self, Type::Text | Type::Xml) } /// HTML link? @@ -60,36 +57,33 @@ impl Type { /// Is this something we can download? pub fn is_download(self) -> bool { - match self { + matches!( + self, Type::Binhex - | Type::DOSFile - | Type::UUEncoded - | Type::Binary - | Type::GIF - | Type::Image - | Type::PNG - | Type::Sound - | Type::Video - | Type::Calendar - | Type::Document => true, - _ => false, - } + | Type::DOSFile + | Type::UUEncoded + | Type::Binary + | Type::GIF + | Type::Image + | Type::PNG + | Type::Sound + | Type::Video + | Type::Calendar + | Type::Document + ) } /// Check if media to open in player pub fn is_media(self) -> bool { - match self { - Type::Sound | Type::Video => true, - _ => false, - } + matches!(self, Type::Sound | Type::Video) } /// Is this a type phetch supports? pub fn is_supported(self) -> bool { - match self { - Type::CSOEntity | Type::Mirror | Type::Telnet3270 | Type::Mailbox => false, - _ => true, - } + !matches!( + self, + Type::CSOEntity | Type::Mirror | Type::Telnet3270 | Type::Mailbox + ) } /// Gopher Item Type to RFC char. diff --git a/src/menu.rs b/src/menu.rs index c867767..ddeadaf 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1000,7 +1000,7 @@ pub fn parse_line(start: usize, raw: &str) -> Option { // if this line contains colors, calculate the visible length and // where to truncate when abiding by `MAX_COLS` - if *&raw[start..text_end].contains("\x1b[") { + if raw[start..text_end].contains("\x1b[") { let mut is_color = false; let mut iter = raw[start..text_end].char_indices(); visible_len = 0; @@ -1010,21 +1010,17 @@ pub fn parse_line(start: usize, raw: &str) -> Option { if c == 'm' { is_color = false; } - } else { - if c == '\x1b' { - if let Some((_, '[')) = iter.next() { - is_color = true; - } - } else { - if visible_len < MAX_COLS { - truncated_len = i; - visible_len += 1; - } else { - truncated_len = i; - visible_len = MAX_COLS + 1; - break; - } + } else if c == '\x1b' { + if let Some((_, '[')) = iter.next() { + is_color = true; } + } else if visible_len < MAX_COLS { + truncated_len = i; + visible_len += 1; + } else { + truncated_len = i; + visible_len = MAX_COLS + 1; + break; } } } diff --git a/src/terminal.rs b/src/terminal.rs index ad61381..d1b40a1 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -5,7 +5,6 @@ use lazy_static::lazy_static; use libc::{cfmakeraw, tcgetattr, tcsetattr, termios as Termios, STDIN_FILENO, TCSANOW}; use std::{io, sync::Mutex}; -use termion; pub use termion::cursor::Goto; pub use termion::cursor::Hide as HideCursor; diff --git a/src/ui.rs b/src/ui.rs index c3e8a12..b31e900 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -26,7 +26,6 @@ use crate::{ text::Text, utils, BUG_URL, }; -use lazy_static; use std::{ io::{stdin, stdout, Result, Write}, process::{self, Stdio}, @@ -236,7 +235,7 @@ impl UI { gopher::download_url(&url, tls, tor, chan) }) .and_then(|res| res) - .and_then(|(path, bytes)| { + .map(|(path, bytes)| { self.set_status( format!( "Download complete! {} saved to {}", @@ -245,7 +244,6 @@ impl UI { ) .as_ref(), ); - Ok(()) }) } diff --git a/src/ui/action.rs b/src/ui/action.rs index 59c0299..744ef86 100644 --- a/src/ui/action.rs +++ b/src/ui/action.rs @@ -33,11 +33,7 @@ pub enum Action { impl Action { /// Is it Action::None? pub fn is_none(&self) -> bool { - if let Action::None = self { - true - } else { - false - } + matches!(self, Action::None) } }