Skip to content

Commit

Permalink
update plurify version
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Jan 28, 2025
1 parent f3e7ed6 commit 2d13f3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ indexmap = "2.7.0"
itertools = "0.14.0"
libspelling = "0.3.0"
openssl = "0.10.68"
plurify = "0.1.1"
plurify = "0.2.0"
syntect = "5.2.0"

# development
Expand Down
3 changes: 2 additions & 1 deletion src/app/browser/window/tab/item/page/search/form/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ impl Result {
// Actions

pub fn update(&self, current: Option<usize>, total: usize) {
use plurify::*;
if total > 0 {
let matches = plurify::ns(total, &["match", "matches", "matches"]);
let matches = total.plurify(&["match", "matches", "matches"]);
match current {
Some(position) => self
.label
Expand Down
4 changes: 3 additions & 1 deletion src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ pub trait Format {

impl Format for usize {
fn bytes(self) -> String {
use plurify::*;

const KB: f32 = 1024.0;
const MB: f32 = KB * KB;
const GB: f32 = MB * KB;

let f = self as f32;

if f < KB {
format!("{self} {}", plurify::ns(self, &["byte", "bytes", "bytes"]))
format!("{self} {}", self.plurify(&["byte", "bytes", "bytes"]))
} else if f < MB {
format!("{:.2} KB", f / KB)
} else if f < GB {
Expand Down

0 comments on commit 2d13f3f

Please sign in to comment.