Skip to main content

collect_bool_words

Function collect_bool_words 

Source
pub fn collect_bool_words<F>(words: &mut [u64], len: usize, f: F)
where F: FnMut(usize) -> bool,
Expand description

Pack len boolean values returned by f into the prefix of words, LSB-first, 64 bits per u64. words must have capacity for at least len.div_ceil(64) entries.

f is invoked exactly once per index, in ascending order 0..len.

Writes via = (not |=), so the destination need not be zero-initialised.

The word loop packs with the baseline SIMD kernel of the target (SSE2 on x86-64, NEON on aarch64), which inlines fully into the caller together with the predicate and the [bool; 64] materialization — wider kernels would sit behind a non-inlinable #[target_feature] boundary that deoptimizes expensive predicates. See BitBuffer::collect_bool for the performance note on avoiding bounds checks in f.

Prefer this entry point for every predicate; only switch to collect_bool_words_multiversioned after carefully checking that your specific f meets its contract.