initial commit

change project name to egui_rpm_installer
This commit is contained in:
2025-11-17 17:07:24 +03:00
commit 640bd6a537
7 changed files with 3884 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
use std::fmt::Write;
pub fn size_to_string(size: f64) -> String {
if size <= 0.0 {
return "-".to_string();
}
const UNITS: [&str; 4] = ["B", "KB", "MB", "GB"];
let i = if size < 1.0 {
0
} else {
size.log(1024.0).floor() as usize
};
let i = i.min(UNITS.len().saturating_sub(1));
let p = 1024_f64.powf(i as f64);
let s = size / p;
let mut buffer = String::with_capacity(10);
write!(&mut buffer, "{:.2} {}", s, UNITS[i]).unwrap();
buffer
}