Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve clippy warnings in nightly #252

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
},
}

impl<'a> Read for CryptoReader<'a> {
impl Read for CryptoReader<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match self {
CryptoReader::Plaintext(r) => r.read(buf),
Expand Down Expand Up @@ -201,7 +201,7 @@
Compressed(Box<Crc32Reader<Decompressor<io::BufReader<CryptoReader<'a>>>>>),
}

impl<'a> Read for ZipFileReader<'a> {
impl Read for ZipFileReader<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match self {
ZipFileReader::NoReader => invalid_state(),
Expand Down Expand Up @@ -282,7 +282,7 @@
}
}

impl<'a, R: Seek> Seek for SeekableTake<'a, R> {
impl<R: Seek> Seek for SeekableTake<'_, R> {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
let offset = match pos {
SeekFrom::Start(offset) => Some(offset),
Expand All @@ -306,7 +306,7 @@
}
}

impl<'a, R: Read> Read for SeekableTake<'a, R> {
impl<R: Read> Read for SeekableTake<'_, R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let written = self
.inner
Expand Down Expand Up @@ -1554,7 +1554,7 @@
/// `foo/../bar` as `foo/bar` (instead of `bar`). Because of this,
/// [`ZipFile::enclosed_name`] is the better option in most scenarios.
///
/// [`ParentDir`]: `PathBuf::Component::ParentDir`

Check warning on line 1557 in src/read.rs

View workflow job for this annotation

GitHub Actions / style_and_docs (--no-default-features)

unresolved link to `PathBuf::Component::ParentDir`

Check warning on line 1557 in src/read.rs

View workflow job for this annotation

GitHub Actions / style_and_docs (--all-features)

unresolved link to `PathBuf::Component::ParentDir`

Check warning on line 1557 in src/read.rs

View workflow job for this annotation

GitHub Actions / style_and_docs

unresolved link to `PathBuf::Component::ParentDir`
pub fn mangled_name(&self) -> PathBuf {
self.get_metadata().file_name_sanitized()
}
Expand Down Expand Up @@ -1652,20 +1652,20 @@
}

/// Methods for retrieving information on zip files
impl<'a> ZipFile<'a> {
impl ZipFile<'_> {
/// iterate through all extra fields
pub fn extra_data_fields(&self) -> impl Iterator<Item = &ExtraField> {
self.data.extra_fields.iter()
}
}

impl<'a> HasZipMetadata for ZipFile<'a> {
impl HasZipMetadata for ZipFile<'_> {
fn get_metadata(&self) -> &ZipFileData {
self.data.as_ref()
}
}

impl<'a> Read for ZipFile<'a> {
impl Read for ZipFile<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.reader.read(buf)
}
Expand All @@ -1683,29 +1683,29 @@
}
}

impl<'a, R: Read> Read for ZipFileSeek<'a, R> {
impl<R: Read> Read for ZipFileSeek<'_, R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match &mut self.reader {
ZipFileSeekReader::Raw(r) => r.read(buf),
}
}
}

impl<'a, R: Seek> Seek for ZipFileSeek<'a, R> {
impl<R: Seek> Seek for ZipFileSeek<'_, R> {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
match &mut self.reader {
ZipFileSeekReader::Raw(r) => r.seek(pos),
}
}
}

impl<'a, R> HasZipMetadata for ZipFileSeek<'a, R> {
impl<R> HasZipMetadata for ZipFileSeek<'_, R> {
fn get_metadata(&self) -> &ZipFileData {
self.data.as_ref()
}
}

impl<'a> Drop for ZipFile<'a> {
impl Drop for ZipFile<'_> {
fn drop(&mut self) {
// self.data is Owned, this reader is constructed by a streaming reader.
// In this case, we want to exhaust the reader so that the next file is accessible.
Expand Down Expand Up @@ -1734,7 +1734,7 @@
/// * `comment`: set to an empty string
/// * `data_start`: set to 0
/// * `external_attributes`: `unix_mode()`: will return None
pub fn read_zipfile_from_stream<'a, R: Read>(reader: &'a mut R) -> ZipResult<Option<ZipFile<'_>>> {
pub fn read_zipfile_from_stream<R: Read>(reader: &mut R) -> ZipResult<Option<ZipFile<'_>>> {
// We can't use the typical ::parse() method, as we follow separate code paths depending on the
// "magic" value (since the magic value will be from the central directory header if we've
// finished iterating over all the actual files).
Expand All @@ -1758,7 +1758,7 @@
Err(e) => return Err(e),
}

let limit_reader = (reader as &'a mut dyn Read).take(result.compressed_size);
let limit_reader = (reader as &mut dyn Read).take(result.compressed_size);

let result_crc32 = result.crc32;
let result_compression_method = result.compression_method;
Expand Down
2 changes: 1 addition & 1 deletion src/read/xz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct BufWriter<'a> {
rest: &'a mut VecDeque<u8>,
}

impl<'a> Write for BufWriter<'a> {
impl Write for BufWriter<'_> {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
if self.inner.len() > *self.written {
let len = std::cmp::min(buf.len(), self.inner.len() - *self.written);
Expand Down
2 changes: 1 addition & 1 deletion src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod write {
/// This is not recommended for new archives, as ZipCrypto is not secure.
fn with_deprecated_encryption(self, password: &[u8]) -> Self;
}
impl<'k, T: FileOptionExtension> FileOptionsExt for FileOptions<'k, T> {
impl<T: FileOptionExtension> FileOptionsExt for FileOptions<'_, T> {
fn with_deprecated_encryption(self, password: &[u8]) -> FileOptions<'static, T> {
self.with_deprecated_encryption(password)
}
Expand Down
8 changes: 4 additions & 4 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
}
}

impl<'k, T: FileOptionExtension> FileOptions<'k, T> {
impl<T: FileOptionExtension> FileOptions<'_, T> {
/// Set the compression method for the new file
///
/// The default is `CompressionMethod::Deflated` if it is enabled. If not,
Expand Down Expand Up @@ -520,7 +520,7 @@
self
}
}
impl<'k> FileOptions<'k, ExtendedFileOptions> {
impl FileOptions<'_, ExtendedFileOptions> {
/// Adds an extra data field.
pub fn add_extra_data(
&mut self,
Expand All @@ -544,7 +544,7 @@
self
}
}
impl<'k, T: FileOptionExtension> Default for FileOptions<'k, T> {
impl<T: FileOptionExtension> Default for FileOptions<'_, T> {
/// Construct a new FileOptions object
fn default() -> Self {
Self {
Expand Down Expand Up @@ -651,8 +651,8 @@
/// read previously-written files and not overwrite them.
///
/// Note: when using an `inner` that cannot overwrite flushed bytes, do not wrap it in a
/// [BufWriter], because that has a [Seek::seek] method that implicitly calls

Check warning on line 654 in src/write.rs

View workflow job for this annotation

GitHub Actions / style_and_docs (--no-default-features)

unresolved link to `BufWriter`
/// [BufWriter::flush], and ZipWriter needs to seek backward to update each file's header with

Check warning on line 655 in src/write.rs

View workflow job for this annotation

GitHub Actions / style_and_docs (--no-default-features)

unresolved link to `BufWriter::flush`
/// the size and checksum after writing the body.
///
/// This setting is false by default.
Expand Down Expand Up @@ -1235,7 +1235,7 @@
/// Add a new file using the already compressed data from a ZIP file being read and renames it, this
/// allows faster copies of the `ZipFile` since there is no need to decompress and compress it again.
/// Any `ZipFile` metadata is copied and not checked, for example the file CRC.

///
/// ```no_run
/// use std::fs::File;
/// use std::io::{Read, Seek, Write};
Expand Down
3 changes: 2 additions & 1 deletion src/zipcrypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl Debug for ZipCryptoKeys {
use std::hash::Hasher;
let mut t = DefaultHasher::new();
self.hash(&mut t);
return f.write_fmt(format_args!("ZipCryptoKeys(hash {})", t.finish()));

f.write_fmt(format_args!("ZipCryptoKeys(hash {})", t.finish()))
}
#[cfg(any(test, fuzzing))]
return f.write_fmt(format_args!(
Expand Down
Loading