Use matcher clause instead of clumsy if expressions

This commit is contained in:
Benjamin Richner 2020-06-23 21:20:30 +02:00
parent fb4f3c5c21
commit 4f36a27c32

View file

@ -396,14 +396,11 @@ impl<R: Read + io::Seek> ZipArchive<R> {
}
let data = &mut self.files[file_number];
if password == None {
if data.encrypted {
return Err(ZipError::PasswordRequired);
}
} else if !data.encrypted {
//Password supplied, but none needed! Discard.
password = None;
}
match (password, data.encrypted) {
(None, true) => return Err(ZipError::PasswordRequired),
(Some(_), false) => password = None, //Password supplied, but none needed! Discard.
_ => {}
}
// Parse local header
self.reader.seek(io::SeekFrom::Start(data.header_start))?;