Skip to content

Commit

Permalink
A few more minor lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Dec 22, 2022
1 parent 2665fab commit 183d413
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
24 changes: 12 additions & 12 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Crc {
}

impl<R: Read> CrcReader<R> {
/// Create a new CrcReader.
/// Create a new `CrcReader`.
pub fn new(r: R) -> CrcReader<R> {
CrcReader {
inner: r,
Expand All @@ -79,27 +79,27 @@ impl<R: Read> CrcReader<R> {
}

impl<R> CrcReader<R> {
/// Get the Crc for this CrcReader.
/// Get the Crc for this `CrcReader`.
pub fn crc(&self) -> &Crc {
&self.crc
}

/// Get the reader that is wrapped by this CrcReader.
/// Get the reader that is wrapped by this `CrcReader`.
pub fn into_inner(self) -> R {
self.inner
}

/// Get the reader that is wrapped by this CrcReader by reference.
/// Get the reader that is wrapped by this `CrcReader` by reference.
pub fn get_ref(&self) -> &R {
&self.inner
}

/// Get a mutable reference to the reader that is wrapped by this CrcReader.
/// Get a mutable reference to the reader that is wrapped by this `CrcReader`.
pub fn get_mut(&mut self) -> &mut R {
&mut self.inner
}

/// Reset the Crc in this CrcReader.
/// Reset the Crc in this `CrcReader`.
pub fn reset(&mut self) {
self.crc.reset();
}
Expand Down Expand Up @@ -135,34 +135,34 @@ pub struct CrcWriter<W> {
}

impl<W> CrcWriter<W> {
/// Get the Crc for this CrcWriter.
/// Get the Crc for this `CrcWriter`.
pub fn crc(&self) -> &Crc {
&self.crc
}

/// Get the writer that is wrapped by this CrcWriter.
/// Get the writer that is wrapped by this `CrcWriter`.
pub fn into_inner(self) -> W {
self.inner
}

/// Get the writer that is wrapped by this CrcWriter by reference.
/// Get the writer that is wrapped by this `CrcWriter` by reference.
pub fn get_ref(&self) -> &W {
&self.inner
}

/// Get a mutable reference to the writer that is wrapped by this CrcWriter.
/// Get a mutable reference to the writer that is wrapped by this `CrcWriter`.
pub fn get_mut(&mut self) -> &mut W {
&mut self.inner
}

/// Reset the Crc in this CrcWriter.
/// Reset the Crc in this `CrcWriter`.
pub fn reset(&mut self) {
self.crc.reset();
}
}

impl<W: Write> CrcWriter<W> {
/// Create a new CrcWriter.
/// Create a new `CrcWriter`.
pub fn new(w: W) -> CrcWriter<W> {
CrcWriter {
inner: w,
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/rust.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Implementation for miniz_oxide rust backend.
//! Implementation for `miniz_oxide` rust backend.

use std::convert::TryInto;
use std::fmt;
Expand Down
4 changes: 2 additions & 2 deletions src/gz/bufread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()>
}
GzHeaderParsingState::Filename => {
if r.part.flg & FNAME != 0 {
if None == r.part.header.filename {
if r.part.header.filename.is_none() {
r.part.header.filename = Some(Vec::new());
};
for byte in r.bytes() {
Expand All @@ -88,7 +88,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()>
}
GzHeaderParsingState::Comment => {
if r.part.flg & FCOMMENT != 0 {
if None == r.part.header.comment {
if r.part.header.comment.is_none() {
r.part.header.comment = Some(Vec::new());
};
for byte in r.bytes() {
Expand Down
4 changes: 2 additions & 2 deletions src/gz/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<W: Write> GzEncoder<W> {
self.inner.finish()?;

while self.crc_bytes_written < 8 {
let (sum, amt) = (self.crc.sum() as u32, self.crc.amount());
let (sum, amt) = (self.crc.sum(), self.crc.amount());
let buf = [
(sum >> 0) as u8,
(sum >> 8) as u8,
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<W: Write> GzDecoder<W> {
| ((self.crc_bytes[5] as u32) << 8)
| ((self.crc_bytes[6] as u32) << 16)
| ((self.crc_bytes[7] as u32) << 24);
if crc != self.inner.get_ref().crc().sum() as u32 {
if crc != self.inner.get_ref().crc().sum() {
return Err(corrupt());
}
if amt != self.inner.get_ref().crc().amount() {
Expand Down
6 changes: 2 additions & 4 deletions src/zio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ where
// then we need to keep asking for more data because if we
// return that 0 bytes of data have been read then it will
// be interpreted as EOF.
Ok(Status::Ok) | Ok(Status::BufError) if read == 0 && !eof && !dst.is_empty() => {
continue
}
Ok(Status::Ok) | Ok(Status::BufError) | Ok(Status::StreamEnd) => return Ok(read),
Ok(Status::Ok | Status::BufError) if read == 0 && !eof && !dst.is_empty() => continue,
Ok(Status::Ok | Status::BufError | Status::StreamEnd) => return Ok(read),

Err(..) => {
return Err(io::Error::new(
Expand Down

0 comments on commit 183d413

Please sign in to comment.