From acd5f935e651f40690bc7bcc59716f779ee061e7 Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 29 Jul 2022 20:08:39 +0200 Subject: [PATCH] Make clippy happy --- src/functions/base.rs | 2 +- src/functions/unakite.rs | 1 + src/functions/users.rs | 6 +++--- src/internal/files.rs | 4 +--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/functions/base.rs b/src/functions/base.rs index 9bf0572..5224eea 100755 --- a/src/functions/base.rs +++ b/src/functions/base.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use log::warn; pub fn install_base_packages(kernel: String) { - let mut kernel_to_install: String = String::new(); + let kernel_to_install: String; std::fs::create_dir_all("/mnt/etc").unwrap(); files::copy_file("/etc/pacman.conf", "/mnt/etc/pacman.conf"); if kernel.is_empty() { diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index 0391eb0..818e5bb 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -154,6 +154,7 @@ pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev "unakite", true, "Cp7oN04ZY0PsA", // unakite + false, ); exec_eval( exec( diff --git a/src/functions/users.rs b/src/functions/users.rs index d9a59a3..78cc4bc 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -5,7 +5,7 @@ use std::process::Command; pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: bool) { if do_hash_pass { let hashed_pass = &*hash_pass(password).stdout; - let password = match std::str::from_utf8(hashed_pass) { + let _password = match std::str::from_utf8(hashed_pass) { Ok(v) => v, Err(e) => panic!("Failed to hash password, invalid UTF-8 sequence {}", e), }; @@ -18,7 +18,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo String::from("-s"), String::from("/bin/bash"), String::from("-p"), - String::from(password).replace("\n", ""), + String::from(password).replace('\n', ""), String::from(username), ], ), @@ -56,7 +56,7 @@ pub fn hash_pass(password: &str) -> std::process::Output { ]) .output() .expect("Failed to hash password"); - return output; + output } diff --git a/src/internal/files.rs b/src/internal/files.rs index 0523fb2..4167da6 100755 --- a/src/internal/files.rs +++ b/src/internal/files.rs @@ -32,9 +32,7 @@ pub fn copy_file(path: &str, destpath: &str) { pub fn append_file(path: &str, content: &str) -> std::io::Result<()> { log::info!("Append '{}' to file {}", content.trim_end(), path); let mut file = OpenOptions::new().append(true).open(path)?; - file.write_all("\n".as_bytes())?; - file.write_all(content.as_bytes())?; - file.write("\n".as_bytes())?; + file.write_all(format!("\n{content}\n").as_bytes())?; Ok(()) }