aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-01-13 21:51:00 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-01-13 21:51:00 +0100
commit84bc13b4dd181d14a100d2d8a3716525c79cd25e (patch)
tree4386fda27048133cc433165a4e83fd0532732a63 /lib
parent3f11980b29cda6340c809aff0c0f1c34e9c3ce26 (diff)
downloadmihi-84bc13b4dd181d14a100d2d8a3716525c79cd25e.tar.gz
mihi-84bc13b4dd181d14a100d2d8a3716525c79cd25e.zip
Fix style issues coming from recent merge
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à <mssola@mssola.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/mihi/src/lib.rs34
1 files changed, 11 insertions, 23 deletions
diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs
index 57dc93f..5c15d8c 100644
--- a/lib/mihi/src/lib.rs
+++ b/lib/mihi/src/lib.rs
@@ -261,13 +261,7 @@ impl Word {
/// Returns whether the given flag is set to true on this word.
pub fn is_flag_set(&self, flag: &str) -> bool {
match self.flags.get(flag) {
- Some(value) => {
- if let Some(b) = value.as_bool() {
- b
- } else {
- false
- }
- }
+ Some(value) => value.as_bool().unwrap_or_default(),
None => false,
}
}
@@ -378,7 +372,7 @@ pub fn create_word(word: Word) -> Result<(), String> {
Category::Verb => match word.conjugation_id {
Some(1..6) => {
if word.kind.as_str() != "verb" {
- return Err(format!("bad kind for verb"));
+ return Err("bad kind for verb".to_string());
}
}
Some(val) => return Err(format!("the conjugation ID '{val}' is not valid")),
@@ -1043,29 +1037,23 @@ fn inflect_from(word: &Word, case: usize, number: usize, gender: usize, term: &s
if !word.regular {
inflections.push(term.to_owned());
} else if contract_root(word, case, number, gender) {
- inflections.push(
- word.particle[0..word.particle.len() - 2].to_string()
- + &"r".to_owned()
- + &term.to_owned(),
- );
+ inflections.push(word.particle[0..word.particle.len() - 2].to_string() + "r" + term);
} else if should_use_first_root(word, case, number, gender) {
let parts: Vec<&str> = word.enunciated.split(',').collect();
- inflections.push(parts.first().unwrap().to_string() + &term.to_owned());
+ inflections.push(parts.first().unwrap().to_string() + term);
} else if word.kind == "ius" && number == 0 {
// Words of this kind are a bit troublesome on the singular, let's
// handle them now.
if case == 1 && word.is_flag_set("contracted_vocative") {
- inflections
- .push(word.particle[0..word.particle.len() - 1].to_string() + &term.to_owned());
+ inflections.push(word.particle[0..word.particle.len() - 1].to_string() + term);
} else {
if case == 3 {
- inflections
- .push(word.particle[0..word.particle.len() - 1].to_string() + &term.to_owned());
+ inflections.push(word.particle[0..word.particle.len() - 1].to_string() + term);
}
- inflections.push(word.particle.to_string() + &term.to_owned());
+ inflections.push(word.particle.to_string() + term);
}
} else {
- inflections.push(word.particle.clone() + &term.to_owned());
+ inflections.push(word.particle.clone() + term);
}
inflections
@@ -1106,9 +1094,9 @@ pub fn group_declension_inflections(
while let Some(row) = it.next().unwrap() {
// Fetch the number and account for defectives on number.
let number: usize = row.get(1).unwrap();
- if number == 0 && word.is_flag_set("onlyplural") {
- continue;
- } else if number == 1 && word.is_flag_set("onlysingular") {
+ if (number == 0 && word.is_flag_set("onlyplural"))
+ || (number == 1 && word.is_flag_set("onlysingular"))
+ {
continue;
}