style: Address warnings

This commit is contained in:
Ed Page 2024-05-02 11:59:32 -05:00
parent a177b1e624
commit 8804d1d2f4
3 changed files with 12 additions and 12 deletions

View file

@ -266,7 +266,7 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult {
// HACK: Diff doesn't handle mixing content // HACK: Diff doesn't handle mixing content
let output_reporter = if args.diff { let output_reporter = if args.diff {
Box::new(crate::report::PrintSilent) Box::new(report::PrintSilent)
} else { } else {
args.format.reporter() args.format.reporter()
}; };

View file

@ -27,12 +27,12 @@ impl BuiltIn {
} }
pub fn correct_word<'s>(&'s self, word_token: typos::tokens::Word<'_>) -> 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 { if word_token.case() == Case::None {
return None; return None;
} }
let word = word_token.token(); let word = word_token.token();
let word_case = unicase::UniCase::new(word); let word_case = UniCase::new(word);
let mut corrections = if let Some(corrections) = self.correct_word_with_dict(word_case) { let mut corrections = if let Some(corrections) = self.correct_word_with_dict(word_case) {
if corrections.is_empty() { if corrections.is_empty() {
Status::Invalid Status::Invalid
@ -85,7 +85,7 @@ impl BuiltIn {
if self.is_vars_enabled() { if self.is_vars_enabled() {
let mut chained: Vec<_> = corrections let mut chained: Vec<_> = corrections
.iter() .iter()
.flat_map(|c| match self.correct_with_vars(unicase::UniCase::new(c)) { .flat_map(|c| match self.correct_with_vars(UniCase::new(c)) {
Some(Status::Valid) | None => vec![Cow::Borrowed(*c)], Some(Status::Valid) | None => vec![Cow::Borrowed(*c)],
Some(Status::Corrections(vars)) => vars, Some(Status::Corrections(vars)) => vars,
Some(Status::Invalid) => { Some(Status::Invalid) => {
@ -283,7 +283,7 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
} }
fn correct_word<'s>(&'s self, word_token: typos::tokens::Word<'_>) -> Option<Status<'s>> { fn correct_word<'s>(&'s self, word_token: typos::tokens::Word<'_>) -> Option<Status<'s>> {
if word_token.case() == typos::tokens::Case::None { if word_token.case() == Case::None {
return None; return None;
} }
@ -319,7 +319,7 @@ mod test {
let dict = BuiltIn::new(crate::config::Locale::default()); let dict = BuiltIn::new(crate::config::Locale::default());
let correction = dict.correct_word(typos::tokens::Word::new_unchecked( let correction = dict.correct_word(typos::tokens::Word::new_unchecked(
"finallizes", "finallizes",
typos::tokens::Case::Lower, Case::Lower,
0, 0,
)); ));
assert_eq!( assert_eq!(
@ -334,7 +334,7 @@ mod test {
let dict = BuiltIn::new(crate::config::Locale::En); let dict = BuiltIn::new(crate::config::Locale::En);
let correction = dict.correct_word(typos::tokens::Word::new_unchecked( let correction = dict.correct_word(typos::tokens::Word::new_unchecked(
"finalizes", "finalizes",
typos::tokens::Case::Lower, Case::Lower,
0, 0,
)); ));
assert_eq!(correction, None); assert_eq!(correction, None);
@ -346,7 +346,7 @@ mod test {
let dict = BuiltIn::new(crate::config::Locale::EnUs); let dict = BuiltIn::new(crate::config::Locale::EnUs);
let correction = dict.correct_word(typos::tokens::Word::new_unchecked( let correction = dict.correct_word(typos::tokens::Word::new_unchecked(
"finalizes", "finalizes",
typos::tokens::Case::Lower, Case::Lower,
0, 0,
)); ));
assert_eq!(correction, Some(Status::Valid)); assert_eq!(correction, Some(Status::Valid));
@ -358,7 +358,7 @@ mod test {
let dict = BuiltIn::new(crate::config::Locale::EnGb); let dict = BuiltIn::new(crate::config::Locale::EnGb);
let correction = dict.correct_word(typos::tokens::Word::new_unchecked( let correction = dict.correct_word(typos::tokens::Word::new_unchecked(
"finalizes", "finalizes",
typos::tokens::Case::Lower, Case::Lower,
0, 0,
)); ));
assert_eq!( assert_eq!(
@ -373,7 +373,7 @@ mod test {
let dict = BuiltIn::new(crate::config::Locale::EnGb); let dict = BuiltIn::new(crate::config::Locale::EnGb);
let correction = dict.correct_word(typos::tokens::Word::new_unchecked( let correction = dict.correct_word(typos::tokens::Word::new_unchecked(
"finallizes", "finallizes",
typos::tokens::Case::Lower, Case::Lower,
0, 0,
)); ));
assert_eq!( assert_eq!(

View file

@ -91,7 +91,7 @@ fn process<S: Into<String>>(
let rows: Vec<_> = rows let rows: Vec<_> = rows
.into_iter() .into_iter()
.filter(|(typo, _)| { .filter(|(typo, _)| {
let is_disallowed = varcon_words.contains(&unicase::UniCase::new(typo)); let is_disallowed = varcon_words.contains(&UniCase::new(typo));
if is_disallowed { if is_disallowed {
eprintln!("{:?} is disallowed; in varcon", typo); eprintln!("{:?} is disallowed; in varcon", typo);
} }
@ -196,7 +196,7 @@ fn varcon_words() -> HashSet<UniCase<&'static str>> {
.iter() .iter()
.flat_map(|c| c.entries.iter()) .flat_map(|c| c.entries.iter())
.flat_map(|e| e.variants.iter()) .flat_map(|e| e.variants.iter())
.map(|v| unicase::UniCase::new(v.word)) .map(|v| UniCase::new(v.word))
.collect() .collect()
} }