From 28a36d80cd0318419ea8d05bbc9918218cbf07d1 Mon Sep 17 00:00:00 2001 From: ascendforever <georgeh124v2@gmail.com> Date: Sun, 13 Oct 2024 18:01:00 -0400 Subject: [PATCH] formatting --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index e446513..a361d4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,8 @@ use std::collections::HashSet; use std::io::Write; use std::path::{Path,PathBuf}; + + #[derive(StructOpt)] #[structopt(about="Recursively get images")] struct CLIArguments { @@ -34,6 +36,8 @@ struct CLIArguments { targets: Vec<String>, } + + fn main() -> Result<(), Box<dyn std::error::Error>>{ let args = { let mut args = CLIArguments::from_args(); @@ -64,8 +68,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>>{ Ok(()) } + + struct Registry<'a> { - registry: Vec<(std::fs::Metadata,PathBuf)>, + registry: Vec<(std::fs::Metadata, PathBuf)>, valid_extensions: HashSet<&'a str> } impl<'a> Registry<'a> { @@ -76,10 +82,10 @@ impl<'a> Registry<'a> { pub fn write_all(&self, writer: &mut impl Write, separator_null: bool, quote: bool) -> std::io::Result<()> { if separator_null { if quote { for (_,file) in &self.registry { write!(writer, "{}\0", shlex::try_quote(&file.to_string_lossy()).unwrap())?; } } - else { for (_,file) in &self.registry { write!(writer, "{}\0", &file.to_string_lossy() )?; } } + else { for (_,file) in &self.registry { write!(writer, "{}\0", &file.to_string_lossy() )?; } } } else { if quote { for (_,file) in &self.registry { writeln!(writer, "{}", shlex::try_quote(&file.to_string_lossy()).unwrap())?; } } - else { for (_,file) in &self.registry { writeln!(writer, "{}", &file.to_string_lossy() )?; } } + else { for (_,file) in &self.registry { writeln!(writer, "{}", &file.to_string_lossy() )?; } } } Ok(()) } @@ -108,7 +114,7 @@ impl<'a> Registry<'a> { if let Some(osstr_ext) = path.extension() { match osstr_ext.to_str() { Some(ext) => if self.valid_extensions.contains(ext) { - self.registry.push((metadata,path)); + self.registry.push((metadata, path)); }, None => eprintln!( "Cannot read non-utf-8 file extension: {} on {}",