Last active: a year ago
Use question mark handle error in map function
pub fn process(&self) -> Result<()> {
match self.mode {
Mode::Format => {
self.file_list
.iter()
.map(|file| self.format_process(file))
.collect::<Result<Vec<_>>>()?;
}
Mode::Compress => {
if self.output.exists() {
fs::remove_dir_all(&self.output)?;
}
fs::create_dir_all(&self.output)?;
self.file_list
.iter()
.map(|path| self.compress_process(path))
.collect::<Result<Vec<_>>>()?;
}
}
Ok(())
}