Use matcher clause instead of clumsy if expressions
This commit is contained in:
parent
fb4f3c5c21
commit
4f36a27c32
1 changed files with 5 additions and 8 deletions
13
src/read.rs
13
src/read.rs
|
@ -396,14 +396,11 @@ impl<R: Read + io::Seek> ZipArchive<R> {
|
||||||
}
|
}
|
||||||
let data = &mut self.files[file_number];
|
let data = &mut self.files[file_number];
|
||||||
|
|
||||||
if password == None {
|
match (password, data.encrypted) {
|
||||||
if data.encrypted {
|
(None, true) => return Err(ZipError::PasswordRequired),
|
||||||
return Err(ZipError::PasswordRequired);
|
(Some(_), false) => password = None, //Password supplied, but none needed! Discard.
|
||||||
}
|
_ => {}
|
||||||
} else if !data.encrypted {
|
}
|
||||||
//Password supplied, but none needed! Discard.
|
|
||||||
password = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse local header
|
// Parse local header
|
||||||
self.reader.seek(io::SeekFrom::Start(data.header_start))?;
|
self.reader.seek(io::SeekFrom::Start(data.header_start))?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue