File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -166,19 +166,13 @@ impl Decode for GzipDecoder {
166
166
output : & mut PartialBuffer < impl AsRef < [ u8 ] > + AsMut < [ u8 ] > > ,
167
167
) -> Result < bool > {
168
168
match & mut self . state {
169
- State :: Done => return Ok ( true ) ,
170
- State :: Header ( parser) => {
171
- // In this case, the input was an empty gzip. Exit successfully with an empty gzip.
172
- if parser. has_no_content ( ) {
173
- return Ok ( true ) ;
174
- }
175
- }
176
- _ => { }
169
+ State :: Done => Ok ( true ) ,
170
+ // In this case, the input was an empty gzip. Exit successfully with an empty gzip.
171
+ State :: Header ( parser) if parser. has_no_content ( ) => Ok ( true ) ,
172
+ _ => Err ( Error :: new (
173
+ ErrorKind :: UnexpectedEof ,
174
+ "unexpected end of file" ,
175
+ ) ) ,
177
176
}
178
-
179
- Err ( Error :: new (
180
- ErrorKind :: UnexpectedEof ,
181
- "unexpected end of file" ,
182
- ) )
183
177
}
184
178
}
Original file line number Diff line number Diff line change 1
1
use crate :: util:: PartialBuffer ;
2
- use std:: io ;
2
+ use std:: { io , iter } ;
3
3
4
4
#[ derive( Debug , Default ) ]
5
5
struct Flags {
@@ -163,9 +163,6 @@ impl Parser {
163
163
}
164
164
165
165
pub ( super ) fn has_no_content ( & self ) -> bool {
166
- match & self . state {
167
- State :: Fixed ( data) => data. buffer ( ) . iter ( ) . all ( |& b| b == 0 ) ,
168
- _ => false ,
169
- }
166
+ matches ! ( & self . state, State :: Fixed ( data) if data. buffer( ) . iter( ) . all( |& b| b == 0 ) )
170
167
}
171
168
}
You can’t perform that action at this time.
0 commit comments