Fixed new Clippy Warnings

This commit is contained in:
Wyatt Herkamp 2022-10-13 07:51:02 -04:00
parent 2b9efe97ba
commit 1c5cd4ffda
7 changed files with 16 additions and 16 deletions

View file

@ -42,7 +42,7 @@ fn real_main() -> i32 {
); );
if let Some(p) = outpath.parent() { if let Some(p) = outpath.parent() {
if !p.exists() { if !p.exists() {
fs::create_dir_all(&p).unwrap(); fs::create_dir_all(p).unwrap();
} }
} }
let mut outfile = fs::File::create(&outpath).unwrap(); let mut outfile = fs::File::create(&outpath).unwrap();

View file

@ -12,7 +12,7 @@ fn real_main() -> i32 {
return 1; return 1;
} }
let fname = std::path::Path::new(&*args[1]); let fname = std::path::Path::new(&*args[1]);
let file = fs::File::open(&fname).unwrap(); let file = fs::File::open(fname).unwrap();
let reader = BufReader::new(file); let reader = BufReader::new(file);
let mut archive = zip::ZipArchive::new(reader).unwrap(); let mut archive = zip::ZipArchive::new(reader).unwrap();

View file

@ -114,7 +114,7 @@ fn doit(
} }
let path = Path::new(dst_file); let path = Path::new(dst_file);
let file = File::create(&path).unwrap(); let file = File::create(path).unwrap();
let walkdir = WalkDir::new(src_dir); let walkdir = WalkDir::new(src_dir);
let it = walkdir.into_iter(); let it = walkdir.into_iter();

View file

@ -23,7 +23,7 @@ fn real_main() -> i32 {
fn doit(filename: &str) -> zip::result::ZipResult<()> { fn doit(filename: &str) -> zip::result::ZipResult<()> {
let path = std::path::Path::new(filename); let path = std::path::Path::new(filename);
let file = std::fs::File::create(&path).unwrap(); let file = std::fs::File::create(path).unwrap();
let mut zip = zip::ZipWriter::new(file); let mut zip = zip::ZipWriter::new(file);

View file

@ -459,7 +459,7 @@ impl<R: Read + io::Seek> ZipArchive<R> {
fs::create_dir_all(&outpath)?; fs::create_dir_all(&outpath)?;
} else { } else {
if let Some(p) = outpath.parent() { if let Some(p) = outpath.parent() {
fs::create_dir_all(&p)?; fs::create_dir_all(p)?;
} }
let mut outfile = fs::File::create(&outpath)?; let mut outfile = fs::File::create(&outpath)?;
io::copy(file, &mut outfile)?; io::copy(file, &mut outfile)?;
@ -686,11 +686,11 @@ pub(crate) fn central_header_to_zip_file<R: Read + io::Seek>(
reader.read_exact(&mut file_comment_raw)?; reader.read_exact(&mut file_comment_raw)?;
let file_name = match is_utf8 { let file_name = match is_utf8 {
true => String::from_utf8_lossy(&*file_name_raw).into_owned(), true => String::from_utf8_lossy(&file_name_raw).into_owned(),
false => file_name_raw.clone().from_cp437(), false => file_name_raw.clone().from_cp437(),
}; };
let file_comment = match is_utf8 { let file_comment = match is_utf8 {
true => String::from_utf8_lossy(&*file_comment_raw).into_owned(), true => String::from_utf8_lossy(&file_comment_raw).into_owned(),
false => file_comment_raw.from_cp437(), false => file_comment_raw.from_cp437(),
}; };
@ -1090,7 +1090,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>(
reader.read_exact(&mut extra_field)?; reader.read_exact(&mut extra_field)?;
let file_name = match is_utf8 { let file_name = match is_utf8 {
true => String::from_utf8_lossy(&*file_name_raw).into_owned(), true => String::from_utf8_lossy(&file_name_raw).into_owned(),
false => file_name_raw.clone().from_cp437(), false => file_name_raw.clone().from_cp437(),
}; };
@ -1134,7 +1134,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>(
return unsupported_zip_error("The file length is not available in the local header"); return unsupported_zip_error("The file length is not available in the local header");
} }
let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size as u64); let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size);
let result_crc32 = result.crc32; let result_crc32 = result.crc32;
let result_compression_method = result.compression_method; let result_compression_method = result.compression_method;

View file

@ -64,12 +64,12 @@ impl CentralDirectoryEnd {
let mut pos = file_length - HEADER_SIZE; let mut pos = file_length - HEADER_SIZE;
while pos >= search_upper_bound { while pos >= search_upper_bound {
reader.seek(io::SeekFrom::Start(pos as u64))?; reader.seek(io::SeekFrom::Start(pos))?;
if reader.read_u32::<LittleEndian>()? == CENTRAL_DIRECTORY_END_SIGNATURE { if reader.read_u32::<LittleEndian>()? == CENTRAL_DIRECTORY_END_SIGNATURE {
reader.seek(io::SeekFrom::Current( reader.seek(io::SeekFrom::Current(
BYTES_BETWEEN_MAGIC_AND_COMMENT_SIZE as i64, BYTES_BETWEEN_MAGIC_AND_COMMENT_SIZE as i64,
))?; ))?;
let cde_start_pos = reader.seek(io::SeekFrom::Start(pos as u64))?; let cde_start_pos = reader.seek(io::SeekFrom::Start(pos))?;
return CentralDirectoryEnd::parse(reader).map(|cde| (cde, cde_start_pos)); return CentralDirectoryEnd::parse(reader).map(|cde| (cde, cde_start_pos));
} }
pos = match pos.checked_sub(1) { pos = match pos.checked_sub(1) {

View file

@ -115,7 +115,7 @@ impl DateTime {
let years = (datepart & 0b1111111000000000) >> 9; let years = (datepart & 0b1111111000000000) >> 9;
DateTime { DateTime {
year: (years + 1980) as u16, year: years + 1980,
month: months as u8, month: months as u8,
day: days as u8, day: days as u8,
hour: hours as u8, hour: hours as u8,
@ -172,10 +172,10 @@ impl DateTime {
Ok(DateTime { Ok(DateTime {
year: (dt.year()) as u16, year: (dt.year()) as u16,
month: (dt.month()) as u8, month: (dt.month()) as u8,
day: dt.day() as u8, day: dt.day(),
hour: dt.hour() as u8, hour: dt.hour(),
minute: dt.minute() as u8, minute: dt.minute(),
second: dt.second() as u8, second: dt.second(),
}) })
} else { } else {
Err(()) Err(())