From 1f2957db1fc459666c11e3bde67d586c097bea2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Iv=C3=A1nek?= Date: Mon, 18 Nov 2024 23:31:26 +0100 Subject: [PATCH] fix: resolve new clippy warnings on nightly (#262) --- src/read/stream.rs | 2 +- src/spec.rs | 2 +- src/types.rs | 2 +- src/write.rs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/read/stream.rs b/src/read/stream.rs index 7fb76e70c..cc602d1dc 100644 --- a/src/read/stream.rs +++ b/src/read/stream.rs @@ -182,7 +182,7 @@ impl ZipStreamFileMetadata { self.name() .chars() .next_back() - .map_or(false, |c| c == '/' || c == '\\') + .is_some_and(|c| c == '/' || c == '\\') } /// Returns whether the file is a regular file diff --git a/src/spec.rs b/src/spec.rs index a75c4481e..1dfb4e5e7 100755 --- a/src/spec.rs +++ b/src/spec.rs @@ -699,7 +699,7 @@ pub(crate) fn is_dir(filename: &str) -> bool { filename .chars() .next_back() - .map_or(false, |c| c == '/' || c == '\\') + .is_some_and(|c| c == '/' || c == '\\') } #[cfg(test)] diff --git a/src/types.rs b/src/types.rs index 1e738b765..de22f6055 100644 --- a/src/types.rs +++ b/src/types.rs @@ -831,7 +831,7 @@ impl ZipFileData { extra_field_length: extra_field_len.checked_add(central_extra_field_len).ok_or( ZipError::InvalidArchive("Extra field length in central directory exceeds 64KiB"), )?, - file_comment_length: self.file_comment.as_bytes().len().try_into().unwrap(), + file_comment_length: self.file_comment.len().try_into().unwrap(), disk_number: 0, internal_file_attributes: 0, external_file_attributes: self.external_attributes, diff --git a/src/write.rs b/src/write.rs index a7c300430..fbd8d18e3 100644 --- a/src/write.rs +++ b/src/write.rs @@ -911,9 +911,9 @@ impl ZipWriter { ), _ => (options.compression_method, None), }; - let header_end = header_start - + size_of::() as u64 - + name.to_string().as_bytes().len() as u64; + let header_end = + header_start + size_of::() as u64 + name.to_string().len() as u64; + if options.alignment > 1 { let extra_data_end = header_end + extra_data.len() as u64; let align = options.alignment as u64;