Skip to content

Commit 6ef136f

Browse files
fix(hashes): resolve clippy manual_is_multiple_of warnings
Replace manual modulo checks with the cleaner is_multiple_of() method: - hashes/src/hex.rs: Check for odd-length hex strings - hashes/src/sha256.rs: Check block size alignment in from_midstate 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 21d6435 commit 6ef136f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

hashes/src/hex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a> HexIterator<'a> {
8686
///
8787
/// If the input string is of odd length.
8888
pub fn new(s: &'a str) -> Result<HexIterator<'a>, Error> {
89-
if s.len() % 2 != 0 {
89+
if !s.len().is_multiple_of(2) {
9090
Err(Error::OddLengthString(s.len()))
9191
} else {
9292
Ok(HexIterator {

hashes/src/sha256.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl HashEngine {
404404
///
405405
/// If `length` is not a multiple of the block size.
406406
pub fn from_midstate(midstate: Midstate, length: usize) -> HashEngine {
407-
assert!(length % BLOCK_SIZE == 0, "length is no multiple of the block size");
407+
assert!(length.is_multiple_of(BLOCK_SIZE), "length is no multiple of the block size");
408408

409409
let mut ret = [0; 8];
410410
for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate[..].chunks_exact(4)) {

0 commit comments

Comments
 (0)