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:
parent
9cd4befc31
commit
7ac9c287ec
1 changed files with 96 additions and 97 deletions
23
src/main.rs
23
src/main.rs
|
@ -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();
|
||||
|
@ -153,10 +153,9 @@ fn main() {
|
|||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue