From 7c6bf5c9a5860cdcdd40eabb9061a2412e7c7e68 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 26 Jul 2024 00:15:26 +0000 Subject: [PATCH] zcash_client_sqlite: Fix `--no-default-features` compilation Closes zcash/librustzcash#1273. --- zcash_client_sqlite/src/lib.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index ba98b988c..afb3d170b 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -33,10 +33,6 @@ #![deny(rustdoc::broken_intra_doc_links)] use incrementalmerkletree::{Marking, Position, Retention}; -use maybe_rayon::{ - prelude::{IndexedParallelIterator, ParallelIterator}, - slice::ParallelSliceMut, -}; use nonempty::NonEmpty; use rusqlite::{self, Connection}; use secrecy::{ExposeSecret, SecretVec}; @@ -95,6 +91,24 @@ use { }, }; +#[cfg(feature = "multicore")] +use maybe_rayon::{ + prelude::{IndexedParallelIterator, ParallelIterator}, + slice::ParallelSliceMut, +}; + +/// `maybe-rayon` doesn't provide this as a fallback, so we have to. +#[cfg(not(feature = "multicore"))] +trait ParallelSliceMut { + fn par_chunks_mut(&mut self, chunk_size: usize) -> std::slice::ChunksMut<'_, T>; +} +#[cfg(not(feature = "multicore"))] +impl ParallelSliceMut for [T] { + fn par_chunks_mut(&mut self, chunk_size: usize) -> std::slice::ChunksMut<'_, T> { + self.chunks_mut(chunk_size) + } +} + #[cfg(feature = "unstable")] use { crate::chain::{fsblockdb_with_blocks, BlockMeta},