remove extra reference

This commit is contained in:
yggverse 2025-01-28 17:31:31 +02:00
parent 6f814dd382
commit f3e7ed60ee

View file

@ -2,19 +2,19 @@
pub trait Format {
/// Format bytes to KB/MB/GB presentation
fn bytes(&self) -> String;
fn bytes(self) -> String;
}
impl Format for usize {
fn bytes(&self) -> String {
fn bytes(self) -> String {
const KB: f32 = 1024.0;
const MB: f32 = KB * KB;
const GB: f32 = MB * KB;
let f = *self as f32;
let f = self as f32;
if f < KB {
format!("{self} {}", plurify::ns(*self, &["byte", "bytes", "bytes"]))
format!("{self} {}", plurify::ns(self, &["byte", "bytes", "bytes"]))
} else if f < MB {
format!("{:.2} KB", f / KB)
} else if f < GB {