Skip to content

Commit 9b938da

Browse files
authored
Merge pull request #347 from Nullus157/fix/clippt
Fix clippy error in async-compression
2 parents aa03267 + 52d7d4c commit 9b938da

File tree

15 files changed

+34
-77
lines changed

15 files changed

+34
-77
lines changed

src/codec/brotli/decoder.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ impl BrotliDecoder {
4040
&mut 0,
4141
&mut self.state,
4242
) {
43-
BrotliResult::ResultFailure => {
44-
return Err(io::Error::new(io::ErrorKind::Other, "brotli error"))
45-
}
43+
BrotliResult::ResultFailure => return Err(io::Error::other("brotli error")),
4644
status => status,
4745
};
4846

src/codec/brotli/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl BrotliEncoder {
4141
&mut None,
4242
&mut |_, _, _, _| (),
4343
) {
44-
return Err(io::Error::new(io::ErrorKind::Other, "brotli error"));
44+
return Err(io::Error::other("brotli error"));
4545
}
4646

4747
input.advance(input_len);

src/codec/bzip2/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl BzDecoder {
3636
let status = self
3737
.decompress
3838
.decompress(input.unwritten(), output.unwritten_mut())
39-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
39+
.map_err(io::Error::other)?;
4040

4141
input.advance((self.decompress.total_in() - prior_in) as usize);
4242
output.advance((self.decompress.total_out() - prior_out) as usize);
@@ -74,7 +74,7 @@ impl Decode for BzDecoder {
7474

7575
// There was insufficient memory in the input or output buffer to complete
7676
// the request, but otherwise everything went normally.
77-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
77+
Status::MemNeeded => Err(io::Error::other("out of memory")),
7878
}
7979
}
8080

src/codec/bzip2/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl BzEncoder {
5757
let status = self
5858
.compress
5959
.compress(input.unwritten(), output.unwritten_mut(), action)
60-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
60+
.map_err(io::Error::other)?;
6161

6262
input.advance((self.compress.total_in() - prior_in) as usize);
6363
output.advance((self.compress.total_out() - prior_out) as usize);
@@ -90,7 +90,7 @@ impl Encode for BzEncoder {
9090

9191
// There was insufficient memory in the input or output buffer to complete
9292
// the request, but otherwise everything went normally.
93-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
93+
Status::MemNeeded => Err(io::Error::other("out of memory")),
9494
}
9595
}
9696

@@ -116,7 +116,7 @@ impl Encode for BzEncoder {
116116

117117
// There was insufficient memory in the input or output buffer to complete
118118
// the request, but otherwise everything went normally.
119-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
119+
Status::MemNeeded => Err(io::Error::other("out of memory")),
120120
}
121121
}
122122

@@ -142,7 +142,7 @@ impl Encode for BzEncoder {
142142

143143
// There was insufficient memory in the input or output buffer to complete
144144
// the request, but otherwise everything went normally.
145-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
145+
Status::MemNeeded => Err(io::Error::other("out of memory")),
146146
}
147147
}
148148
}

src/codec/flate/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Decode for FlateDecoder {
5151
match self.decode(input, output, FlushDecompress::None)? {
5252
Status::Ok => Ok(false),
5353
Status::StreamEnd => Ok(true),
54-
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
54+
Status::BufError => Err(io::Error::other("unexpected BufError")),
5555
}
5656
}
5757

@@ -91,7 +91,7 @@ impl Decode for FlateDecoder {
9191
)? {
9292
Status::Ok => Ok(false),
9393
Status::StreamEnd => Ok(true),
94-
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
94+
Status::BufError => Err(io::Error::other("unexpected BufError")),
9595
}
9696
}
9797
}

src/codec/flate/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Encode for FlateEncoder {
5151
match self.encode(input, output, FlushCompress::None)? {
5252
Status::Ok => Ok(()),
5353
Status::StreamEnd => unreachable!(),
54-
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
54+
Status::BufError => Err(io::Error::other("unexpected BufError")),
5555
}
5656
}
5757

@@ -100,7 +100,7 @@ impl Encode for FlateEncoder {
100100
)? {
101101
Status::Ok => Ok(false),
102102
Status::StreamEnd => Ok(true),
103-
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
103+
Status::BufError => Err(io::Error::other("unexpected BufError")),
104104
}
105105
}
106106
}

src/codec/gzip/encoder.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ impl Encode for GzipEncoder {
7272
}
7373

7474
State::Footer(_) | State::Done => {
75-
return Err(io::Error::new(
76-
io::ErrorKind::Other,
77-
"encode after complete",
78-
));
75+
return Err(io::Error::other("encode after complete"));
7976
}
8077
};
8178

src/codec/gzip/header.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ impl Parser {
156156
}
157157

158158
State::Done => {
159-
return Err(io::Error::new(
160-
io::ErrorKind::Other,
161-
"parser used after done",
162-
));
159+
return Err(io::Error::other("parser used after done"));
163160
}
164161
};
165162
}

src/codec/xz2/decoder.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ impl Decode for Xz2Decoder {
4646
match status {
4747
Status::Ok => Ok(false),
4848
Status::StreamEnd => Ok(true),
49-
Status::GetCheck => Err(io::Error::new(
50-
io::ErrorKind::Other,
51-
"Unexpected lzma integrity check",
52-
)),
53-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "More memory needed")),
49+
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
50+
Status::MemNeeded => Err(io::Error::other("More memory needed")),
5451
}
5552
}
5653

@@ -77,11 +74,8 @@ impl Decode for Xz2Decoder {
7774
match status {
7875
Status::Ok => Ok(false),
7976
Status::StreamEnd => Ok(true),
80-
Status::GetCheck => Err(io::Error::new(
81-
io::ErrorKind::Other,
82-
"Unexpected lzma integrity check",
83-
)),
84-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "More memory needed")),
77+
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
78+
Status::MemNeeded => Err(io::Error::other("More memory needed")),
8579
}
8680
}
8781
}

src/codec/xz2/encoder.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ impl Encode for Xz2Encoder {
4848

4949
match status {
5050
Status::Ok | Status::StreamEnd => Ok(()),
51-
Status::GetCheck => Err(io::Error::new(
52-
io::ErrorKind::Other,
53-
"Unexpected lzma integrity check",
54-
)),
55-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
51+
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
52+
Status::MemNeeded => Err(io::Error::other("out of memory")),
5653
}
5754
}
5855

@@ -71,11 +68,8 @@ impl Encode for Xz2Encoder {
7168
match status {
7269
Status::Ok => Ok(false),
7370
Status::StreamEnd => Ok(true),
74-
Status::GetCheck => Err(io::Error::new(
75-
io::ErrorKind::Other,
76-
"Unexpected lzma integrity check",
77-
)),
78-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
71+
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
72+
Status::MemNeeded => Err(io::Error::other("out of memory")),
7973
}
8074
}
8175

@@ -94,11 +88,8 @@ impl Encode for Xz2Encoder {
9488
match status {
9589
Status::Ok => Ok(false),
9690
Status::StreamEnd => Ok(true),
97-
Status::GetCheck => Err(io::Error::new(
98-
io::ErrorKind::Other,
99-
"Unexpected lzma integrity check",
100-
)),
101-
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
91+
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
92+
Status::MemNeeded => Err(io::Error::other("out of memory")),
10293
}
10394
}
10495
}

0 commit comments

Comments
 (0)