Clean up whitespaces

This commit is contained in:
Benjamin Richner 2020-05-21 22:14:53 +02:00
parent cf7ff173b3
commit f9116fc9c8
2 changed files with 9 additions and 9 deletions

View file

@ -144,11 +144,11 @@ fn make_reader<'a>(
reader: io::Take<&'a mut dyn io::Read>, reader: io::Take<&'a mut dyn io::Read>,
password: Option<&[u8]>) password: Option<&[u8]>)
-> ZipResult<ZipFileReader<'a>> { -> ZipResult<ZipFileReader<'a>> {
let reader = match password let reader = match password
{ {
None => CryptoReader::Plaintext(reader), None => CryptoReader::Plaintext(reader),
Some(password) => Some(password) =>
{ {
match ZipCryptoReader::new(reader, password).validate(crc32)? match ZipCryptoReader::new(reader, password).validate(crc32)?
{ {
@ -157,7 +157,7 @@ fn make_reader<'a>(
} }
} }
}; };
match compression_method match compression_method
{ {
CompressionMethod::Stored => CompressionMethod::Stored =>
@ -353,7 +353,7 @@ impl<R: Read+io::Seek> ZipArchive<R>
}; };
self.by_index_internal(index, password) self.by_index_internal(index, password)
} }
/// Get a contained file by index, decrypt with given password /// Get a contained file by index, decrypt with given password
pub fn by_index_decrypt<'a>(&'a mut self, file_number: usize, password: &[u8]) -> ZipResult<ZipFile<'a>> pub fn by_index_decrypt<'a>(&'a mut self, file_number: usize, password: &[u8]) -> ZipResult<ZipFile<'a>>
{ {
@ -365,12 +365,12 @@ impl<R: Read+io::Seek> ZipArchive<R>
{ {
self.by_index_internal(file_number, None) self.by_index_internal(file_number, None)
} }
fn by_index_internal<'a>(&'a mut self, file_number: usize, mut password: Option<&[u8]>) -> ZipResult<ZipFile<'a>> fn by_index_internal<'a>(&'a mut self, file_number: usize, mut password: Option<&[u8]>) -> ZipResult<ZipFile<'a>>
{ {
if file_number >= self.files.len() { return Err(ZipError::FileNotFound); } if file_number >= self.files.len() { return Err(ZipError::FileNotFound); }
let ref mut data = self.files[file_number]; let ref mut data = self.files[file_number];
if password == None if password == None
{ {
if data.encrypted if data.encrypted
@ -623,7 +623,7 @@ impl<'a> Drop for ZipFile<'a> {
// Get the inner `Take` reader so all decryption, decompression and CRC calculation is skipped. // Get the inner `Take` reader so all decryption, decompression and CRC calculation is skipped.
let innerreader = ::std::mem::replace(&mut self.reader, ZipFileReader::NoReader); let innerreader = ::std::mem::replace(&mut self.reader, ZipFileReader::NoReader);
let mut reader : std::io::Take<&mut dyn std::io::Read> = let mut reader : std::io::Take<&mut dyn std::io::Read> =
innerreader.into_inner(); innerreader.into_inner();
loop { loop {

View file

@ -23,10 +23,10 @@ pub enum ZipError
/// The requested file could not be found in the archive /// The requested file could not be found in the archive
FileNotFound, FileNotFound,
/// No password was given but the data is encrypted /// No password was given but the data is encrypted
PasswordRequired, PasswordRequired,
/// The given password is wrong /// The given password is wrong
InvalidPassword, InvalidPassword,
} }