pipecircuit 0.0.16

Correct. Robust. Fast. Portable.
Documentation
#[inline]
pub(super) fn reduce(word: u64, bucket_count: usize) -> usize {
    let Ok(bucket_count) = u64::try_from(bucket_count) else {
        return 0;
    };
    let product = u128::from(word).wrapping_mul(u128::from(bucket_count));
    usize::try_from(product >> 64).unwrap_or_default()
}

#[inline]
pub(super) fn next_bucket(bucket: usize, bucket_count: usize) -> usize {
    if bucket == bucket_count.saturating_sub(1) {
        0
    } else {
        bucket.saturating_add(1)
    }
}

#[inline]
pub(super) fn probe_distance(ideal: usize, bucket: usize, bucket_count: usize) -> usize {
    bucket.wrapping_sub(ideal) & bucket_count.saturating_sub(1)
}