Skip to content

Commit

Permalink
Simplify io:Error creation
Browse files Browse the repository at this point in the history
A lot of errors were created using io::Error::from(io::ErrorKind::*), which can be replaced with the more concise io::ErrorKind::*.into().
  • Loading branch information
AronParker committed Apr 23, 2022
1 parent 0a39d06 commit cae7fd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl<R: BufRead> DecompressorReader<R> {
} else {
Err(IntoInnerError::new(
self,
io::Error::from(io::ErrorKind::UnexpectedEof),
io::ErrorKind::UnexpectedEof.into(),
))
}
}
Expand Down Expand Up @@ -547,7 +547,7 @@ impl<R: BufRead> Read for DecompressorReader<R> {
_ if bytes_written > 0 => return Ok(bytes_written),
DecoderInfo::Finished => return Ok(0),
DecoderInfo::NeedsMoreInput if eof => {
return Err(io::Error::from(io::ErrorKind::UnexpectedEof));
return Err(io::ErrorKind::UnexpectedEof.into());
}
DecoderInfo::NeedsMoreInput => continue,
DecoderInfo::NeedsMoreOutput if buf.is_empty() => return Ok(0),
Expand Down Expand Up @@ -654,7 +654,7 @@ impl<W: Write> DecompressorWriter<W> {
} else {
Err(IntoInnerError::new(
self,
io::Error::from(io::ErrorKind::UnexpectedEof),
io::ErrorKind::UnexpectedEof.into(),
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<R: BufRead> CompressorReader<R> {
} else {
Err(IntoInnerError::new(
self,
io::Error::from(io::ErrorKind::UnexpectedEof),
io::ErrorKind::UnexpectedEof.into(),
))
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ pub use decode::DecompressorReader;
pub use decode::DecompressorWriter;

use brotlic_sys::*;
use std::io::ErrorKind;
use std::os::raw::c_int;
use std::{fmt, io};
use std::error::Error;
Expand Down Expand Up @@ -745,7 +744,7 @@ impl Error for CompressError {}

impl From<CompressError> for io::Error {
fn from(err: CompressError) -> Self {
io::Error::new(ErrorKind::Other, err)
io::Error::new(io::ErrorKind::Other, err)
}
}

Expand All @@ -763,7 +762,7 @@ impl Error for DecompressError {}

impl From<DecompressError> for io::Error {
fn from(err: DecompressError) -> Self {
io::Error::new(ErrorKind::Other, err)
io::Error::new(io::ErrorKind::Other, err)
}
}

Expand Down

0 comments on commit cae7fd5

Please sign in to comment.