1
Fork 0
mirror of https://github.com/RGBCube/dix synced 2025-07-28 04:07:46 +00:00

src/main.rs: cleanup

This commit is contained in:
Bloxx12 2025-05-04 22:24:56 +02:00
parent 9cd4befc31
commit 7ac9c287ec
No known key found for this signature in database

View file

@ -27,10 +27,11 @@ struct Args {
closure_size: bool,
}
// Only there to make the compiler shut up for now.
#[derive(Debug)]
enum BlaErr {
LolErr,
struct Package<'a> {
name: &'a str,
versions: HashSet<&'a str>,
/// Save if a package is a dependency of another package
is_dep: bool,
}
fn main() {
@ -57,7 +58,6 @@ fn main() {
let package_list_pre = get_packages(&args.path);
let package_list_post = get_packages(&args.path2);
if let (Ok(package_list_pre), Ok(package_list_post)) = (package_list_pre, package_list_post) {
// Map from packages of the first closure to their version
let mut pre = HashMap::<&str, HashSet<&str>>::new();
@ -152,11 +152,10 @@ fn main() {
println!("After: {post_size} MiB");
println!("Difference: {} MiB", post_size - pre_size);
}
}
}
// gets the packages in a closure
fn get_packages(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
fn get_packages(path: &std::path::Path) -> Vec<String> {
// get the nix store paths using nix-store --query --references <path>
let references = Command::new("nix-store")
.arg("--query")
@ -169,14 +168,14 @@ fn get_packages(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
if let Ok(list) = list {
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
return Ok(res);
return res;
}
}
Err(BlaErr::LolErr)
Vec::new()
}
// gets the dependencies of the packages in a closure
fn get_dependencies(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
fn get_dependencies(path: &std::path::Path) -> Vec<String> {
// get the nix store paths using nix-store --query --references <path>
let references = Command::new("nix-store")
.arg("--query")
@ -189,10 +188,10 @@ fn get_dependencies(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
if let Ok(list) = list {
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
return Ok(res);
return res;
}
}
Err(BlaErr::LolErr)
Vec::new()
}
fn get_version<'a>(pack: impl Into<&'a str>) -> (&'a str, &'a str) {