diff --git a/Cargo.toml b/Cargo.toml index 230c1890..79c0656b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,9 @@ version = "0.9.1" package = "sourceview5" version = "0.9.1" +[dependencies.plurify] +version = "0.1.0" + # development [patch.crates-io] # ggemini = { git = "https://github.com/YGGverse/ggemini.git" } diff --git a/src/app/browser/window/tab/item/page/search/form/result.rs b/src/app/browser/window/tab/item/page/search/form/result.rs index ea4a248d..053880e4 100644 --- a/src/app/browser/window/tab/item/page/search/form/result.rs +++ b/src/app/browser/window/tab/item/page/search/form/result.rs @@ -24,7 +24,7 @@ impl Result { pub fn update(&self, current: Option, total: usize) { if total > 0 { - let matches = plural(total, &["match", "matches", "matches"]); + let matches = plurify::ns(total, &["match", "matches", "matches"]); match current { Some(position) => self .label @@ -38,13 +38,3 @@ impl Result { } } } - -// Tools - -fn plural<'a>(n: usize, s: &[&'a str]) -> &'a str { - s[if (n % 100) > 4 && (n % 100) < 20 { - 2 - } else { - [2, 0, 1, 1, 1, 2][std::cmp::min(n % 10, 5)] - }] -}