Skip to content

Commit

Permalink
CryptoPals: Rust: convert some error handlers based on clippy advice
Browse files Browse the repository at this point in the history
This is actually a false posative where clippy thinks an enum
constructor is a function call:
rust-lang/rust-clippy#1338
  • Loading branch information
giodamelio committed Sep 25, 2018
1 parent 2c9a25f commit f1cf42b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cryptopals/rust/src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ pub fn string_to_bytes(input: &str) -> Result<Vec<u8>, HexToBytesError> {
.map(|chunk| {
let chunk0 = chunk[0]
.to_digit(16)
.ok_or(HexToBytesError::InvalidChar(chunk[0]))?;
.ok_or_else(|| HexToBytesError::InvalidChar(chunk[0]))?;
let chunk1 = chunk[1]
.to_digit(16)
.ok_or(HexToBytesError::InvalidChar(chunk[1]))?;
.ok_or_else(|| HexToBytesError::InvalidChar(chunk[1]))?;
Ok(((chunk0 << 4) | chunk1) as u8)
}).collect()
}
Expand Down

0 comments on commit f1cf42b

Please sign in to comment.