run cargo fix --edition

This commit is contained in:
Lachezar Lechev 2019-11-11 08:58:59 +02:00
parent 6fbcc33d82
commit 99dba6b397
No known key found for this signature in database
GPG key ID: B2D641D6A2C8E742
9 changed files with 46 additions and 46 deletions

View file

@ -48,7 +48,7 @@ fn real_main() -> i32 {
return 0;
}
fn zip_dir<T>(it: &mut Iterator<Item=DirEntry>, prefix: &str, writer: T, method: zip::CompressionMethod)
fn zip_dir<T>(it: &mut dyn Iterator<Item=DirEntry>, prefix: &str, writer: T, method: zip::CompressionMethod)
-> zip::result::ZipResult<()>
where T: Write+Seek
{

View file

@ -41,7 +41,7 @@ fn to_char(input: u8) -> char
{
let output = match input
{
0x00 ... 0x7f => input as u32,
0x00 ..= 0x7f => input as u32,
0x80 => 0x00c7,
0x81 => 0x00fc,
0x82 => 0x00e9,

View file

@ -11,10 +11,10 @@ extern crate podio;
#[cfg(feature = "time")]
extern crate time;
pub use read::ZipArchive;
pub use write::ZipWriter;
pub use compression::CompressionMethod;
pub use types::DateTime;
pub use crate::read::ZipArchive;
pub use crate::write::ZipWriter;
pub use crate::compression::CompressionMethod;
pub use crate::types::DateTime;
mod spec;
mod crc32;

View file

@ -1,17 +1,17 @@
//! Structs for reading a ZIP archive
use crc32::Crc32Reader;
use compression::CompressionMethod;
use spec;
use result::{ZipResult, ZipError};
use crate::crc32::Crc32Reader;
use crate::compression::CompressionMethod;
use crate::spec;
use crate::result::{ZipResult, ZipError};
use std::io;
use std::io::prelude::*;
use std::collections::HashMap;
use std::borrow::Cow;
use podio::{ReadPodExt, LittleEndian};
use types::{ZipFileData, System, DateTime};
use cp437::FromCp437;
use crate::types::{ZipFileData, System, DateTime};
use crate::cp437::FromCp437;
#[cfg(feature = "deflate")]
use flate2;
@ -64,11 +64,11 @@ pub struct ZipArchive<R: Read + io::Seek>
enum ZipFileReader<'a> {
NoReader,
Stored(Crc32Reader<io::Take<&'a mut Read>>),
Stored(Crc32Reader<io::Take<&'a mut dyn Read>>),
#[cfg(feature = "deflate")]
Deflated(Crc32Reader<flate2::read::DeflateDecoder<io::Take<&'a mut Read>>>),
Deflated(Crc32Reader<flate2::read::DeflateDecoder<io::Take<&'a mut dyn Read>>>),
#[cfg(feature = "bzip2")]
Bzip2(Crc32Reader<BzDecoder<io::Take<&'a mut Read>>>),
Bzip2(Crc32Reader<BzDecoder<io::Take<&'a mut dyn Read>>>),
}
/// A struct for reading a zip file
@ -84,9 +84,9 @@ fn unsupported_zip_error<T>(detail: &'static str) -> ZipResult<T>
fn make_reader<'a>(
compression_method: ::compression::CompressionMethod,
compression_method: crate::compression::CompressionMethod,
crc32: u32,
reader: io::Take<&'a mut io::Read>)
reader: io::Take<&'a mut dyn io::Read>)
-> ZipResult<ZipFileReader<'a>> {
match compression_method {
@ -289,7 +289,7 @@ impl<R: Read+io::Seek> ZipArchive<R>
data.data_start = data.header_start + magic_and_header + file_name_length + extra_field_length;
self.reader.seek(io::SeekFrom::Start(data.data_start))?;
let limit_reader = (self.reader.by_ref() as &mut Read).take(data.compressed_size);
let limit_reader = (self.reader.by_ref() as &mut dyn Read).take(data.compressed_size);
Ok(ZipFile { reader: make_reader(data.compression_method, data.crc32, limit_reader)?, data: Cow::Borrowed(data) })
}
@ -414,20 +414,20 @@ fn parse_extra_field(file: &mut ZipFileData, data: &[u8]) -> ZipResult<()>
Ok(())
}
fn get_reader<'a>(reader: &'a mut ZipFileReader) -> &'a mut Read {
fn get_reader<'a>(reader: &'a mut ZipFileReader) -> &'a mut dyn Read {
match *reader {
ZipFileReader::NoReader => panic!("ZipFileReader was in an invalid state"),
ZipFileReader::Stored(ref mut r) => r as &mut Read,
ZipFileReader::Stored(ref mut r) => r as &mut dyn Read,
#[cfg(feature = "deflate")]
ZipFileReader::Deflated(ref mut r) => r as &mut Read,
ZipFileReader::Deflated(ref mut r) => r as &mut dyn Read,
#[cfg(feature = "bzip2")]
ZipFileReader::Bzip2(ref mut r) => r as &mut Read,
ZipFileReader::Bzip2(ref mut r) => r as &mut dyn Read,
}
}
/// Methods for retrieving information on zip files
impl<'a> ZipFile<'a> {
fn get_reader(&mut self) -> &mut Read {
fn get_reader(&mut self) -> &mut dyn Read {
get_reader(&mut self.reader)
}
/// Get the version of the file
@ -630,7 +630,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>(reader: &'a mut R) -> ZipResult
return unsupported_zip_error("The file length is not available in the local header");
}
let limit_reader = (reader as &'a mut io::Read).take(result.compressed_size as u64);
let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size as u64);
let result_crc32 = result.crc32;
let result_compression_method = result.compression_method;

View file

@ -34,7 +34,7 @@ impl ZipError
match *self
{
ZipError::Io(ref io_err) => {
("Io Error: ".to_string() + (io_err as &error::Error).description()).into()
("Io Error: ".to_string() + (io_err as &dyn error::Error).description()).into()
},
ZipError::InvalidArchive(msg) | ZipError::UnsupportedArchive(msg) => {
(self.description().to_string() + ": " + msg).into()
@ -76,18 +76,18 @@ impl error::Error for ZipError
{
match *self
{
ZipError::Io(ref io_err) => (io_err as &error::Error).description(),
ZipError::Io(ref io_err) => (io_err as &dyn error::Error).description(),
ZipError::InvalidArchive(..) => "Invalid Zip archive",
ZipError::UnsupportedArchive(..) => "Unsupported Zip archive",
ZipError::FileNotFound => "Specified file not found in archive",
}
}
fn cause(&self) -> Option<&error::Error>
fn cause(&self) -> Option<&dyn error::Error>
{
match *self
{
ZipError::Io(ref io_err) => Some(io_err as &error::Error),
ZipError::Io(ref io_err) => Some(io_err as &dyn error::Error),
_ => None,
}
}

View file

@ -1,6 +1,6 @@
use std::io;
use std::io::prelude::*;
use result::{ZipResult, ZipError};
use crate::result::{ZipResult, ZipError};
use podio::{ReadPodExt, WritePodExt, LittleEndian};
pub const LOCAL_FILE_HEADER_SIGNATURE : u32 = 0x04034b50;

View file

@ -202,7 +202,7 @@ pub struct ZipFileData
/// True if the file is encrypted.
pub encrypted: bool,
/// Compression method used to store the file
pub compression_method: ::compression::CompressionMethod,
pub compression_method: crate::compression::CompressionMethod,
/// Last modified time. This will only have a 2 second precision.
pub last_modified_time: DateTime,
/// CRC32 checksum
@ -258,7 +258,7 @@ impl ZipFileData {
pub fn version_needed(&self) -> u16 {
match self.compression_method {
#[cfg(feature = "bzip2")]
::compression::CompressionMethod::Bzip2 => 46,
crate::compression::CompressionMethod::Bzip2 => 46,
_ => 20,
}
}
@ -283,7 +283,7 @@ mod test {
system: System::Dos,
version_made_by: 0,
encrypted: false,
compression_method: ::compression::CompressionMethod::Stored,
compression_method: crate::compression::CompressionMethod::Stored,
last_modified_time: DateTime::default(),
crc32: 0,
compressed_size: 0,

View file

@ -1,10 +1,10 @@
//! Structs for creating a new zip archive
use compression::CompressionMethod;
use types::{ZipFileData, System, DEFAULT_VERSION, DateTime};
use spec;
use crate::compression::CompressionMethod;
use crate::types::{ZipFileData, System, DEFAULT_VERSION, DateTime};
use crate::spec;
use crc32fast::Hasher;
use result::{ZipResult, ZipError};
use crate::result::{ZipResult, ZipError};
use std::default::Default;
use std::io;
use std::io::prelude::*;
@ -395,13 +395,13 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
Ok(())
}
fn ref_mut(&mut self) -> Option<&mut Write> {
fn ref_mut(&mut self) -> Option<&mut dyn Write> {
match *self {
GenericZipWriter::Storer(ref mut w) => Some(w as &mut Write),
GenericZipWriter::Storer(ref mut w) => Some(w as &mut dyn Write),
#[cfg(feature = "deflate")]
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut Write),
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write),
#[cfg(feature = "bzip2")]
GenericZipWriter::Bzip2(ref mut w) => Some(w as &mut Write),
GenericZipWriter::Bzip2(ref mut w) => Some(w as &mut dyn Write),
GenericZipWriter::Closed => None,
}
}
@ -563,9 +563,9 @@ fn path_to_string(path: &std::path::Path) -> String {
mod test {
use std::io;
use std::io::Write;
use types::DateTime;
use crate::types::DateTime;
use super::{FileOptions, ZipWriter};
use compression::CompressionMethod;
use crate::compression::CompressionMethod;
#[test]
fn write_empty_zip() {

View file

@ -167,16 +167,16 @@ impl Read for Zip64File {
return Ok(0);
}
match self.pointer {
BLOCK1_START ... BLOCK1_END => {
BLOCK1_START ..= BLOCK1_END => {
buf[0] = BLOCK1[(self.pointer - BLOCK1_START) as usize];
},
BLOCK2_START ... BLOCK2_END => {
BLOCK2_START ..= BLOCK2_END => {
buf[0] = BLOCK2[(self.pointer - BLOCK2_START) as usize];
},
BLOCK3_START ... BLOCK3_END => {
BLOCK3_START ..= BLOCK3_END => {
buf[0] = BLOCK3[(self.pointer - BLOCK3_START) as usize];
},
BLOCK4_START ... BLOCK4_END => {
BLOCK4_START ..= BLOCK4_END => {
buf[0] = BLOCK4[(self.pointer - BLOCK4_START) as usize];
},
_ => {