From a640e7f0aefa2b63d3497c4b25b2a400de73538b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 26 Oct 2023 06:08:08 +1100 Subject: [PATCH 1/2] ci: Pin memchr for MSRV build Recently `memchr` started using edition 2021 in a patch release, this breaks our MSRV build. Pin it. --- contrib/test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/test.sh b/contrib/test.sh index 634b28c..277fdc5 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -3,6 +3,7 @@ set -ex FEATURES="std alloc core2" +MSRV="1\.48\.0" cargo --version rustc --version @@ -13,6 +14,11 @@ if cargo --version | grep nightly >/dev/null; then NIGHTLY=true fi +if cargo --version | grep ${MSRV}; then + # memchr 2.6.0 uses edition 2021 + cargo update -p memchr --precise 2.5.0 +fi + # Make all cargo invocations verbose export CARGO_TERM_VERBOSE=true From cce557474f64fe0f4d3aa9df18af245c1e82f427 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 25 Oct 2023 15:30:23 +1100 Subject: [PATCH 2/2] Remove unnecessary use of vec macro Clippy emits: error: useless use of `vec!` As suggested, remove the macro call. Rename the variable to `bytes` instead of `v` to better suit the new array type. --- src/iter.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/iter.rs b/src/iter.rs index f8f6d5b..c92635f 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -207,39 +207,39 @@ mod tests { #[test] fn decode_iter_forward() { let hex = "deadbeef"; - let v = vec![0xde, 0xad, 0xbe, 0xef]; + let bytes = [0xde, 0xad, 0xbe, 0xef]; for (i, b) in HexToBytesIter::new(hex).unwrap().enumerate() { - assert_eq!(b.unwrap(), v[i]); + assert_eq!(b.unwrap(), bytes[i]); } } #[test] fn decode_iter_backward() { let hex = "deadbeef"; - let v = vec![0xef, 0xbe, 0xad, 0xde]; + let bytes = [0xef, 0xbe, 0xad, 0xde]; for (i, b) in HexToBytesIter::new(hex).unwrap().rev().enumerate() { - assert_eq!(b.unwrap(), v[i]); + assert_eq!(b.unwrap(), bytes[i]); } } #[test] fn encode_iter() { - let v = vec![0xde, 0xad, 0xbe, 0xef]; + let bytes = [0xde, 0xad, 0xbe, 0xef]; let hex = "deadbeef"; - for (i, c) in BytesToHexIter::new(v.iter().cloned()).enumerate() { + for (i, c) in BytesToHexIter::new(bytes.iter().cloned()).enumerate() { assert_eq!(c, hex.chars().nth(i).unwrap()); } } #[test] fn encode_iter_backwards() { - let v = vec![0xde, 0xad, 0xbe, 0xef]; + let bytes = [0xde, 0xad, 0xbe, 0xef]; let hex = "efbeadde"; - for (i, c) in BytesToHexIter::new(v.iter().cloned()).rev().enumerate() { + for (i, c) in BytesToHexIter::new(bytes.iter().cloned()).rev().enumerate() { assert_eq!(c, hex.chars().nth(i).unwrap()); } }