mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
remove extra reference
This commit is contained in:
parent
6f814dd382
commit
f3e7ed60ee
1 changed files with 4 additions and 4 deletions
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
pub trait Format {
|
pub trait Format {
|
||||||
/// Format bytes to KB/MB/GB presentation
|
/// Format bytes to KB/MB/GB presentation
|
||||||
fn bytes(&self) -> String;
|
fn bytes(self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Format for usize {
|
impl Format for usize {
|
||||||
fn bytes(&self) -> String {
|
fn bytes(self) -> String {
|
||||||
const KB: f32 = 1024.0;
|
const KB: f32 = 1024.0;
|
||||||
const MB: f32 = KB * KB;
|
const MB: f32 = KB * KB;
|
||||||
const GB: f32 = MB * KB;
|
const GB: f32 = MB * KB;
|
||||||
|
|
||||||
let f = *self as f32;
|
let f = self as f32;
|
||||||
|
|
||||||
if f < KB {
|
if f < KB {
|
||||||
format!("{self} {}", plurify::ns(*self, &["byte", "bytes", "bytes"]))
|
format!("{self} {}", plurify::ns(self, &["byte", "bytes", "bytes"]))
|
||||||
} else if f < MB {
|
} else if f < MB {
|
||||||
format!("{:.2} KB", f / KB)
|
format!("{:.2} KB", f / KB)
|
||||||
} else if f < GB {
|
} else if f < GB {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue