Skip to content

Commit

Permalink
fix: resolve clippy warning in nightly (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
RisaI authored Oct 21, 2024
1 parent 6d39456 commit 0663292
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
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 @@ pub(crate) enum CryptoReader<'a> {
},
}

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 @@ pub(crate) enum ZipFileReader<'a> {
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> SeekableTake<'a, R> {
}
}

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: Seek> Seek for SeekableTake<'a, R> {
}
}

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 @@ -1652,20 +1652,20 @@ impl<'a> ZipFile<'a> {
}

/// 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> Read for ZipFile<'a> {
}
}

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 @@ impl<'a> Drop for ZipFile<'a> {
/// * `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 @@ pub fn read_zipfile_from_stream<'a, R: Read>(reader: &'a mut R) -> ZipResult<Opt
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<'a> arbitrary::Arbitrary<'a> for FileOptions<'a, ExtendedFileOptions> {
}
}

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 @@ impl<'k, T: FileOptionExtension> FileOptions<'k, T> {
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 @@ impl<'k> FileOptions<'k, ExtendedFileOptions> {
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 @@ -1235,7 +1235,7 @@ impl<W: Write + Seek> ZipWriter<W> {
/// 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

0 comments on commit 0663292

Please sign in to comment.