From e18fb0ba63076c0970cb5bf4f1fdc6e728c619e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuomas=20M=C3=A4kinen?= Date: Wed, 10 Jan 2024 16:07:52 +0200 Subject: [PATCH] Drop use of array_chunks feature from nightly --- crates/node/src/lib.rs | 1 - crates/node/src/types/hash.rs | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index b92ac123..e33c9045 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(array_chunks)] pub mod rpc_client; pub mod types; diff --git a/crates/node/src/types/hash.rs b/crates/node/src/types/hash.rs index 89ea7501..5e32044b 100644 --- a/crates/node/src/types/hash.rs +++ b/crates/node/src/types/hash.rs @@ -66,8 +66,15 @@ impl From<&[u8]> for Hash { impl From for Message { fn from(value: Hash) -> Self { - // Split [u8; 32] into 8 * [u8; 4] - let mut chunks = value.0.array_chunks::<4>(); + let chunk_sz = HASH_SIZE/8; + let mut offset = 0; + let mut chunks = vec![]; + for _ in 0..value.0.len()/chunk_sz { + chunks.push(<&[u8] as TryInto<[u8; 4]>>::try_into(&value.0[offset..offset+chunk_sz]).unwrap().clone()); + offset += chunk_sz; + } + + let mut chunks = chunks.iter_mut(); Message(libsecp256k1::curve::Scalar([ u32::from_be_bytes(*chunks.next().unwrap()), u32::from_be_bytes(*chunks.next().unwrap()),