diff --git a/src/dict.rs b/src/dict.rs index fbc7df9..d587525 100644 --- a/src/dict.rs +++ b/src/dict.rs @@ -1,5 +1,6 @@ include!(concat!(env!("OUT_DIR"), "/codegen.rs")); +#[derive(Default)] pub struct Dictionary {} impl Dictionary { @@ -29,6 +30,6 @@ fn map_lookup( // See https://github.com/rust-lang/rust/issues/28853#issuecomment-158735548 unsafe { let key = ::std::mem::transmute::<_, &'static str>(key); - map.get(&UniCase(key)).map(|s| *s) + map.get(&UniCase(key)).cloned() } } diff --git a/src/lib.rs b/src/lib.rs index 86156a9..d707770 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ pub fn process_file( for (line_idx, line) in grep_searcher::LineIter::new(b'\n', &buffer).enumerate() { let line_num = line_idx + 1; for token in tokens::Symbol::parse(line) { - if let Some(word) = std::str::from_utf8(token.token).ok() { + if let Ok(word) = std::str::from_utf8(token.token) { // Correct tokens as-is if let Some(correction) = dictionary.correct_str(word) { let col_num = token.offset; diff --git a/src/main.rs b/src/main.rs index 6a652e9..386bacf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,10 +51,8 @@ struct Options { impl Options { pub fn infer(mut self) -> Self { - if self.path.len() == 1 { - if self.path[0].is_file() { - self.threads = 1; - } + if self.path.len() == 1 && self.path[0].is_file() { + self.threads = 1; } self diff --git a/src/tokens.rs b/src/tokens.rs index f3ca3a1..70948da 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -9,7 +9,7 @@ impl<'t> Symbol<'t> { Self { token, offset } } - pub fn parse<'s>(content: &'s [u8]) -> impl Iterator> { + pub fn parse(content: &[u8]) -> impl Iterator> { lazy_static::lazy_static! { static ref SPLIT: regex::bytes::Regex = regex::bytes::Regex::new(r#"\b(\p{Alphabetic}|\d|_)+\b"#).unwrap(); }