Skip to content

Commit 291fa80

Browse files
committed
Take an opportunity to use Option::ok_or_else
I did quite a bit of this in the transcoder, but never thought to check elsewhere until I saw clippy::option_if_let_else. Sadly, its suggestion is the unreadable Option::map_or_else rather than this simpler form. That makes me disinclined to enable this across the board.
1 parent 35a58f3 commit 291fa80

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/yaml/encoding.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,7 @@ where
365365
self.pos += next.len() as u64;
366366

367367
let unit = self.endianness.decode_u32(next);
368-
Some(match char::from_u32(unit) {
369-
Some(ch) => Ok(ch),
370-
None => Err(EncodingError::new(unit, pos).into()),
371-
})
368+
Some(char::from_u32(unit).ok_or_else(|| EncodingError::new(unit, pos).into()))
372369
}
373370
}
374371

0 commit comments

Comments
 (0)