From 84bc13b4dd181d14a100d2d8a3716525c79cd25e Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 13 Jan 2026 21:51:00 +0100 Subject: Fix style issues coming from recent merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I apparently merged the 'inflection' branch without checking the code style. This means that a lot of warnings are being raised by clippy and I'm unsure which commit did what. Since I'm lazy about this right now, let's bring all fixes in a single commit. Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/exercises.rs | 4 +-- crates/cli/src/inflection.rs | 70 ++++++++++++++++++++++---------------------- crates/cli/src/run.rs | 4 +-- crates/cli/src/words.rs | 11 ++++--- 4 files changed, 44 insertions(+), 45 deletions(-) (limited to 'crates/cli/src') diff --git a/crates/cli/src/exercises.rs b/crates/cli/src/exercises.rs index b153aca..518f604 100644 --- a/crates/cli/src/exercises.rs +++ b/crates/cli/src/exercises.rs @@ -4,8 +4,8 @@ use std::vec::IntoIter; // Show the help message. fn help(msg: Option<&str>) { - if msg.is_some() { - println!("{}.\n", msg.unwrap()); + if let Some(msg) = msg { + println!("{}.\n", msg); } println!("mihi exercises: Manage exercises.\n"); diff --git a/crates/cli/src/inflection.rs b/crates/cli/src/inflection.rs index f42d1e8..05c4c70 100644 --- a/crates/cli/src/inflection.rs +++ b/crates/cli/src/inflection.rs @@ -29,18 +29,18 @@ fn print_noun_inflection(word: &Word) -> Result<(), String> { println!( "Nominative:\t{}", - get_inflected_from(&word, &table.nominative) + get_inflected_from(word, &table.nominative) ); - println!("Vocative:\t{}", get_inflected_from(&word, &table.vocative)); + println!("Vocative:\t{}", get_inflected_from(word, &table.vocative)); println!( "Accusative:\t{}", - get_inflected_from(&word, &table.accusative) + get_inflected_from(word, &table.accusative) ); - println!("Genitive:\t{}", get_inflected_from(&word, &table.genitive)); - println!("Dative:\t\t{}", get_inflected_from(&word, &table.dative)); - println!("Ablative:\t{}", get_inflected_from(&word, &table.ablative)); + println!("Genitive:\t{}", get_inflected_from(word, &table.genitive)); + println!("Dative:\t\t{}", get_inflected_from(word, &table.dative)); + println!("Ablative:\t{}", get_inflected_from(word, &table.ablative)); if word.locative { - println!("Locative:\t{}", get_inflected_from(&word, &table.locative)); + println!("Locative:\t{}", get_inflected_from(word, &table.locative)); } Ok(()) @@ -78,46 +78,46 @@ fn print_adjective_inflection(word: &Word) -> Result<(), String> { println!( "Nominative:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].nominative), - get_inflected_from(&word, &tables[1].nominative), - get_inflected_from(&word, &tables[2].nominative) + get_inflected_from(word, &tables[0].nominative), + get_inflected_from(word, &tables[1].nominative), + get_inflected_from(word, &tables[2].nominative) ); println!( "Vocative:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].vocative), - get_inflected_from(&word, &tables[1].vocative), - get_inflected_from(&word, &tables[2].vocative) + get_inflected_from(word, &tables[0].vocative), + get_inflected_from(word, &tables[1].vocative), + get_inflected_from(word, &tables[2].vocative) ); println!( "Accusative:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].accusative), - get_inflected_from(&word, &tables[1].accusative), - get_inflected_from(&word, &tables[2].accusative) + get_inflected_from(word, &tables[0].accusative), + get_inflected_from(word, &tables[1].accusative), + get_inflected_from(word, &tables[2].accusative) ); println!( "Genitive:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].genitive), - get_inflected_from(&word, &tables[1].genitive), - get_inflected_from(&word, &tables[2].genitive) + get_inflected_from(word, &tables[0].genitive), + get_inflected_from(word, &tables[1].genitive), + get_inflected_from(word, &tables[2].genitive) ); println!( "Dative:\t\t{} | {} | {}", - get_inflected_from(&word, &tables[0].dative), - get_inflected_from(&word, &tables[1].dative), - get_inflected_from(&word, &tables[2].dative) + get_inflected_from(word, &tables[0].dative), + get_inflected_from(word, &tables[1].dative), + get_inflected_from(word, &tables[2].dative) ); println!( "Ablative:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].ablative), - get_inflected_from(&word, &tables[1].ablative), - get_inflected_from(&word, &tables[2].ablative) + get_inflected_from(word, &tables[0].ablative), + get_inflected_from(word, &tables[1].ablative), + get_inflected_from(word, &tables[2].ablative) ); if word.locative { println!( "Locative:\t{} | {} | {}", - get_inflected_from(&word, &tables[0].locative), - get_inflected_from(&word, &tables[1].locative), - get_inflected_from(&word, &tables[2].locative) + get_inflected_from(word, &tables[0].locative), + get_inflected_from(word, &tables[1].locative), + get_inflected_from(word, &tables[2].locative) ); } @@ -161,20 +161,20 @@ mod tests { } fn stringify_with(word: &Word, table: &DeclensionTable) -> String { - let mut res = get_inflected_from(&word, &table.nominative); + let mut res = get_inflected_from(word, &table.nominative); res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.vocative).as_str()); + res.push_str(get_inflected_from(word, &table.vocative).as_str()); res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.accusative).as_str()); + res.push_str(get_inflected_from(word, &table.accusative).as_str()); res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.genitive).as_str()); + res.push_str(get_inflected_from(word, &table.genitive).as_str()); res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.dative).as_str()); + res.push_str(get_inflected_from(word, &table.dative).as_str()); res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.ablative).as_str()); + res.push_str(get_inflected_from(word, &table.ablative).as_str()); if word.locative { res.push_str(" | "); - res.push_str(get_inflected_from(&word, &table.locative).as_str()); + res.push_str(get_inflected_from(word, &table.locative).as_str()); } res diff --git a/crates/cli/src/run.rs b/crates/cli/src/run.rs index 10e0721..5d121d2 100644 --- a/crates/cli/src/run.rs +++ b/crates/cli/src/run.rs @@ -13,8 +13,8 @@ use crate::locale::{current_locale, Locale}; const MAX_STEPS: usize = 5; fn help(msg: Option<&str>) { - if msg.is_some() { - println!("{}.\n", msg.unwrap()); + if let Some(msg) = msg { + println!("{}.\n", msg); } println!("mihi run: Run exercises. Default command if none was given.\n"); diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index 23a3946..60609a9 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -57,8 +57,8 @@ static FLAGS_TEXT: &str = r#"# Write a JSON blob with the following allowed keys // Show the help message. fn help(msg: Option<&str>) { - if msg.is_some() { - println!("{}.\n", msg.unwrap()); + if let Some(msg) = msg { + println!("{}.\n", msg); } println!("mihi words: Manage words.\n"); @@ -613,8 +613,8 @@ fn show_info(word: Word) -> Result<(), String> { // TODO: to_human match word.conjugation_id { Some(id) => println!("Conjugation: {}", id), - None => match word.declension_id { - Some(did) => { + None => { + if let Some(did) = word.declension_id { if did > 5 { println!("Declension: {}", humanize_kind(&word.kind)); } else { @@ -625,8 +625,7 @@ fn show_info(word: Word) -> Result<(), String> { ); } } - None => {} - }, + } }; // Show translation if available. -- cgit v1.2.3