@@ -185,13 +185,9 @@ impl FileMetadata {
185
185
- usize:: from ( FileMetadata :: FOOTER_STRUCT_FLAGS_LENGTH )
186
186
+ usize:: from ( byte_number) ;
187
187
188
- let mut flag_byte = match footer_bytes. get ( byte_offset) {
189
- None => Err ( Error :: new (
190
- ErrorKind :: DataInvalid ,
191
- "Index range is out of bounds." ,
192
- ) ) ,
193
- Some ( byte) => Ok ( * byte) ,
194
- } ?;
188
+ let mut flag_byte = * footer_bytes. get ( byte_offset) . ok_or_else ( || {
189
+ Error :: new ( ErrorKind :: DataInvalid , "Index range is out of bounds." )
190
+ } ) ?;
195
191
let mut bit_number = 0 ;
196
192
while flag_byte != 0 {
197
193
if flag_byte & 0x1 != 0 {
@@ -229,13 +225,9 @@ impl FileMetadata {
229
225
let start_offset = usize:: from ( FileMetadata :: MAGIC_LENGTH ) ;
230
226
let end_offset =
231
227
usize:: from ( FileMetadata :: MAGIC_LENGTH ) + usize:: try_from ( footer_payload_length) ?;
232
- let footer_payload_bytes = match footer_bytes. get ( start_offset..end_offset) {
233
- None => Err ( Error :: new (
234
- ErrorKind :: DataInvalid ,
235
- "Index range is out of bounds." ,
236
- ) ) ,
237
- Some ( data) => Ok ( data) ,
238
- } ?;
228
+ let footer_payload_bytes = footer_bytes
229
+ . get ( start_offset..end_offset)
230
+ . ok_or_else ( || Error :: new ( ErrorKind :: DataInvalid , "Index range is out of bounds." ) ) ?;
239
231
let decompressed_footer_payload_bytes =
240
232
footer_compression_codec. decompress ( footer_payload_bytes. into ( ) ) ?;
241
233
0 commit comments