mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 23:52:12 -05:00
style: Make clippy happy
This commit is contained in:
parent
67ca12a847
commit
0c05b217d4
8 changed files with 31 additions and 44 deletions
|
@ -7,7 +7,7 @@ fn codegen() {
|
|||
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let content = codegenrs::rustfmt(&content, None).unwrap();
|
||||
snapbox::assert_eq_path("./src/dict_codegen.rs", &content);
|
||||
snapbox::assert_eq_path("./src/dict_codegen.rs", content);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -28,9 +28,9 @@ impl<V> DictTrie<V> {
|
|||
match child.children {
|
||||
DictTrieChild::Nested(n) => {
|
||||
let byte = bytes[i];
|
||||
let index = if (b'a'..=b'z').contains(&byte) {
|
||||
let index = if byte.is_ascii_lowercase() {
|
||||
byte - b'a'
|
||||
} else if (b'A'..=b'Z').contains(&byte) {
|
||||
} else if byte.is_ascii_uppercase() {
|
||||
byte - b'A'
|
||||
} else {
|
||||
return self.unicode.find(word);
|
||||
|
|
|
@ -3,10 +3,11 @@ use clap::Parser;
|
|||
|
||||
use typos_cli::config;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, clap::ValueEnum)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, clap::ValueEnum, Default)]
|
||||
pub enum Format {
|
||||
Silent,
|
||||
Brief,
|
||||
#[default]
|
||||
Long,
|
||||
Json,
|
||||
}
|
||||
|
@ -32,12 +33,6 @@ impl Format {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Format {
|
||||
fn default() -> Self {
|
||||
Format::Long
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
#[command(about, author, version)]
|
||||
|
|
|
@ -483,7 +483,9 @@ impl Eq for DictConfig {}
|
|||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Default)]
|
||||
pub enum Locale {
|
||||
#[default]
|
||||
En,
|
||||
EnUs,
|
||||
EnGb,
|
||||
|
@ -507,12 +509,6 @@ impl Locale {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Locale {
|
||||
fn default() -> Self {
|
||||
Locale::En
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Locale {
|
||||
type Err = String;
|
||||
|
||||
|
|
|
@ -18,17 +18,14 @@ impl BuiltIn {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn correct_ident<'s, 'w>(
|
||||
pub fn correct_ident<'s>(
|
||||
&'s self,
|
||||
_ident: typos::tokens::Identifier<'w>,
|
||||
_ident: typos::tokens::Identifier<'_>,
|
||||
) -> Option<Status<'s>> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn correct_word<'s, 'w>(
|
||||
&'s self,
|
||||
word_token: typos::tokens::Word<'w>,
|
||||
) -> Option<Status<'s>> {
|
||||
pub fn correct_word<'s>(&'s self, word_token: typos::tokens::Word<'_>) -> Option<Status<'s>> {
|
||||
if word_token.case() == typos::tokens::Case::None {
|
||||
return None;
|
||||
}
|
||||
|
@ -162,11 +159,11 @@ impl BuiltIn {
|
|||
}
|
||||
|
||||
impl typos::Dictionary for BuiltIn {
|
||||
fn correct_ident<'s, 'w>(&'s self, ident: typos::tokens::Identifier<'w>) -> Option<Status<'s>> {
|
||||
fn correct_ident<'s>(&'s self, ident: typos::tokens::Identifier<'_>) -> Option<Status<'s>> {
|
||||
BuiltIn::correct_ident(self, ident)
|
||||
}
|
||||
|
||||
fn correct_word<'s, 'w>(&'s self, word: typos::tokens::Word<'w>) -> Option<Status<'s>> {
|
||||
fn correct_word<'s>(&'s self, word: typos::tokens::Word<'_>) -> Option<Status<'s>> {
|
||||
BuiltIn::correct_word(self, word)
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +243,7 @@ impl<'i, 'w, D: typos::Dictionary> Override<'i, 'w, D> {
|
|||
}
|
||||
|
||||
impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
|
||||
fn correct_ident<'s, 't>(&'s self, ident: typos::tokens::Identifier<'t>) -> Option<Status<'s>> {
|
||||
fn correct_ident<'s>(&'s self, ident: typos::tokens::Identifier<'_>) -> Option<Status<'s>> {
|
||||
for ignored in &self.ignored_identifiers {
|
||||
if ignored.is_match(ident.token()) {
|
||||
return Some(Status::Valid);
|
||||
|
@ -264,7 +261,7 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
|
|||
}
|
||||
}
|
||||
|
||||
fn correct_word<'s, 't>(&'s self, word: typos::tokens::Word<'t>) -> Option<Status<'s>> {
|
||||
fn correct_word<'s>(&'s self, word: typos::tokens::Word<'_>) -> Option<Status<'s>> {
|
||||
if word.case() == typos::tokens::Case::None {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ fn parse_dict(path: &str) -> Vec<(String, Vec<String>)> {
|
|||
|
||||
reader
|
||||
.records()
|
||||
.into_iter()
|
||||
.map(Result::unwrap)
|
||||
.map(|record| {
|
||||
let mut iter = record.into_iter();
|
||||
|
|
|
@ -5,12 +5,12 @@ pub trait Dictionary: Send + Sync {
|
|||
/// Look up the validity of an Identifier.
|
||||
///
|
||||
/// `None` if the status is unknown.
|
||||
fn correct_ident<'s, 'w>(&'s self, ident: crate::tokens::Identifier<'w>) -> Option<Status<'s>>;
|
||||
fn correct_ident<'s>(&'s self, ident: crate::tokens::Identifier<'_>) -> Option<Status<'s>>;
|
||||
|
||||
/// Look up the validity of a Word.
|
||||
///
|
||||
/// `None` if the status is unknown.
|
||||
fn correct_word<'s, 'w>(&'s self, word: crate::tokens::Word<'w>) -> Option<Status<'s>>;
|
||||
fn correct_word<'s>(&'s self, word: crate::tokens::Word<'_>) -> Option<Status<'s>>;
|
||||
}
|
||||
|
||||
/// Validity of a term in a Dictionary.
|
||||
|
|
|
@ -510,21 +510,21 @@ mod parser {
|
|||
#[inline]
|
||||
fn is_lower_hex_digit(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='f').contains(&c) || ('0'..='9').contains(&c)
|
||||
('a'..='f').contains(&c) || c.is_ascii_digit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_upper_hex_digit(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('A'..='F').contains(&c) || ('0'..='9').contains(&c)
|
||||
('A'..='F').contains(&c) || c.is_ascii_digit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_base64_digit(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='z').contains(&c)
|
||||
|| ('A'..='Z').contains(&c)
|
||||
|| ('0'..='9').contains(&c)
|
||||
c.is_ascii_lowercase()
|
||||
|| c.is_ascii_uppercase()
|
||||
|| c.is_ascii_digit()
|
||||
|| c == '+'
|
||||
|| c == '/'
|
||||
}
|
||||
|
@ -538,18 +538,18 @@ mod parser {
|
|||
#[inline]
|
||||
fn is_localport_char(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='z').contains(&c)
|
||||
|| ('A'..='Z').contains(&c)
|
||||
|| ('0'..='9').contains(&c)
|
||||
c.is_ascii_lowercase()
|
||||
|| c.is_ascii_uppercase()
|
||||
|| c.is_ascii_digit()
|
||||
|| "!#$%&'*+-/=?^_`{|}~().".find(c).is_some()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_domain_char(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='z').contains(&c)
|
||||
|| ('A'..='Z').contains(&c)
|
||||
|| ('0'..='9').contains(&c)
|
||||
c.is_ascii_lowercase()
|
||||
|| c.is_ascii_uppercase()
|
||||
|| c.is_ascii_digit()
|
||||
|| "-().".find(c).is_some()
|
||||
}
|
||||
|
||||
|
@ -568,9 +568,9 @@ mod parser {
|
|||
#[inline]
|
||||
fn is_uri_unreserved(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='z').contains(&c)
|
||||
|| ('A'..='Z').contains(&c)
|
||||
|| ('0'..='9').contains(&c)
|
||||
c.is_ascii_lowercase()
|
||||
|| c.is_ascii_uppercase()
|
||||
|| c.is_ascii_digit()
|
||||
|| "-._~".find(c).is_some()
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ mod parser {
|
|||
#[inline]
|
||||
fn is_scheme_char(i: impl AsChar + Copy) -> bool {
|
||||
let c = i.as_char();
|
||||
('a'..='z').contains(&c) || ('0'..='9').contains(&c) || "+.-".find(c).is_some()
|
||||
c.is_ascii_lowercase() || c.is_ascii_digit() || "+.-".find(c).is_some()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Reference in a new issue