From 989688421eaaed3b17f0cbf83190c98d6e77afb4 Mon Sep 17 00:00:00 2001 From: WFL Repo Warden Date: Sat, 29 Aug 2026 00:56:03 -0500 Subject: [PATCH] fix(stdlib): use as_chunks in hex_to_bytes for clippy 1.98 Rust 1.98.0 (released 2026-08-18) promotes `clippy::chunks_exact_to_as_chunks` into the default lint set. Both CI lanes run `-D warnings`, so the single `chunks_exact(2)` call in `hex_to_bytes` became a hard compile error and took down the nightly Windows build (run 33235732094) and CI on main (run 33173832824). No behaviour change. The length guard above the call already rejects odd-length input, so `as_chunks::<2>()`'s remainder half is always empty and discarding it drops nothing. Each pair now arrives as `&[u8; 2]` instead of a runtime-length slice, which is what the lint is asking for; byte-oriented decoding (and therefore the multi-byte-safety property the doc comment describes) is unchanged. `slice::as_chunks` is stable since 1.88.0, comfortably under the crate's 1.94 MSRV. --- src/stdlib/crypto.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stdlib/crypto.rs b/src/stdlib/crypto.rs index 1bfd1be1..09e9a718 100644 --- a/src/stdlib/crypto.rs +++ b/src/stdlib/crypto.rs @@ -1045,8 +1045,14 @@ fn hex_to_bytes(hex: &str) -> Option> { if !bytes.len().is_multiple_of(2) { return None; } + // The length guard above makes the remainder half of `as_chunks` always + // empty, so discarding it drops nothing. `as_chunks::<2>` is preferred over + // `chunks_exact(2)` because the constant chunk size is carried in the type: + // each pair arrives as `&[u8; 2]` rather than a runtime-length slice. bytes - .chunks_exact(2) + .as_chunks::<2>() + .0 + .iter() .map(|pair| { // Rejects any non-ASCII byte: hex is ASCII by definition. let text = std::str::from_utf8(pair).ok()?;