From acf26d6e90534fb43577d1f25feadf776cf18d05 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 12 Feb 2026 14:05:55 +0100 Subject: [PATCH] refactor(build): format using cargo fmt --- build.rs | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/build.rs b/build.rs index 714ecdd..cf4c318 100644 --- a/build.rs +++ b/build.rs @@ -1,21 +1,13 @@ use std::{ collections::HashMap, - fs::{ - self, - DirEntry, - ReadDir, - write, - }, + fs::{self, DirEntry, ReadDir, write}, io, - path::{ - Path, - PathBuf - } + path::{Path, PathBuf}, }; const COMMAND_DIR: &str = "./src/commands/"; const EVENT_DIR: &str = "./src/events"; -const MOD_PREFIX: &str= "pub mod "; +const MOD_PREFIX: &str = "pub mod "; fn clear_name(s: &mut String, n: usize) -> String { if n >= s.len() { @@ -35,7 +27,10 @@ fn read_dir(dir: &Path) -> Vec { for entry in fs::read_dir(dir).unwrap() { let entry: DirEntry = entry.unwrap(); let pb: PathBuf = entry.path(); - if pb.is_file() && pb.to_string_lossy().ends_with(".rs") && !pb.to_string_lossy().ends_with("mod.rs") { + if pb.is_file() + && pb.to_string_lossy().ends_with(".rs") + && !pb.to_string_lossy().ends_with("mod.rs") + { dir_content.push(clear_name(pb.to_string_lossy().to_mut(), len)); } } @@ -53,7 +48,7 @@ fn list_srcs(dir: &Path) -> HashMap> { let pb: PathBuf = entry.path(); let filename: &str = &pb.to_string_lossy(); let len: usize = filename.rfind('/').expect("") + 1; - if pb.is_dir() { + if pb.is_dir() { let subdir: Vec = read_dir(pb.as_path()); to_ret.insert(clear_name(pb.to_string_lossy().to_mut(), len), subdir); } @@ -72,10 +67,16 @@ fn commands() -> io::Result<()> { submodules = String::from(MOD_PREFIX) + command + &String::from(";\n"); println!("\t'{}'", command); } - write(String::from(COMMAND_DIR) + subdir + &String::from("/mod.rs"), submodules)?; + write( + String::from(COMMAND_DIR) + subdir + &String::from("/mod.rs"), + submodules, + )?; modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n"); } - write(String::from(COMMAND_DIR) + &String::from("/mod.rs"), modules)?; + write( + String::from(COMMAND_DIR) + &String::from("/mod.rs"), + modules, + )?; Ok(()) } @@ -91,7 +92,10 @@ fn events() -> io::Result<()> { submodules = String::from(MOD_PREFIX) + event + &String::from(";\n"); println!("\t'{}'", event); } - write(String::from(EVENT_DIR) + subdir + &String::from("/mod.rs"), submodules)?; + write( + String::from(EVENT_DIR) + subdir + &String::from("/mod.rs"), + submodules, + )?; modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n"); } write(String::from(EVENT_DIR) + &String::from("/mod.rs"), modules)?;