From 9d65fc5e12a0bbf1b9d5ee7457c50d9097b5fd5c Mon Sep 17 00:00:00 2001 From: Will Manning Date: Wed, 3 Jul 2024 11:01:53 -0400 Subject: [PATCH] fmt --- benches/bitpacking.rs | 5 ++++- src/bitpacking.rs | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/benches/bitpacking.rs b/benches/bitpacking.rs index 81e7614..75f798c 100644 --- a/benches/bitpacking.rs +++ b/benches/bitpacking.rs @@ -55,7 +55,10 @@ fn pack(c: &mut Criterion) { b.iter(|| { for i in 0..1024 { - black_box::(BitPacking::unpack_single::(array_ref![packed, 0, 192], i)); + black_box::(BitPacking::unpack_single::( + array_ref![packed, 0, 192], + i, + )); } }); }); diff --git a/src/bitpacking.rs b/src/bitpacking.rs index 57e751c..89c2e32 100644 --- a/src/bitpacking.rs +++ b/src/bitpacking.rs @@ -1,9 +1,8 @@ +use arrayref::{array_mut_ref, array_ref}; use core::mem::size_of; +use paste::paste; use crate::{pack, seq_t, unpack, FastLanes, Pred, Satisfied, FL_ORDER}; -use arrayref::{array_mut_ref, array_ref}; -use paste::paste; -use seq_macro::seq; pub struct BitPackWidth; pub trait SupportedBitPackWidth {} @@ -43,7 +42,11 @@ pub trait BitPacking: FastLanes { /// These lengths are checked only with `debug_assert` (i.e., not checked on release builds). unsafe fn unchecked_unpack(width: usize, input: &[Self], output: &mut [Self]); - fn unpack_single(input: &[Self; 1024 * W / Self::T], index: usize) -> Self { + /// Unpacks a single element at the provided index from a packed array of 1024 `W` bit elements. + fn unpack_single(packed: &[Self; 1024 * W / Self::T], index: usize) -> Self + where + BitPackWidth: SupportedBitPackWidth, + { // Special case for W=0, since there's only one possible value. if W == 0 { return Self::zero(); @@ -96,13 +99,13 @@ pub trait BitPacking: FastLanes { (lo | hi) & mask } - // Unpacks a single element at the provided index from a packed array of 1024 `W` bit elements, - // where `W` is runtime-known instead of compile-time known. - // - // # Safety - // The input slice must be of length `1024 * W / T`, where `T` is the bit-width of Self and `W` - // is the packed width. The output slice must be of exactly length 1024. - // These lengths are checked only with `debug_assert` (i.e., not checked on release builds). + /// Unpacks a single element at the provided index from a packed array of 1024 `W` bit elements, + /// where `W` is runtime-known instead of compile-time known. + /// + /// # Safety + /// The input slice must be of length `1024 * W / T`, where `T` is the bit-width of Self and `W` + /// is the packed width. The output slice must be of exactly length 1024. + /// These lengths are checked only with `debug_assert` (i.e., not checked on release builds). unsafe fn unchecked_unpack_single(width: usize, input: &[Self], index: usize) -> Self; } @@ -177,7 +180,7 @@ macro_rules! impl_packing { } }) } - + unsafe fn unchecked_unpack_single(width: usize, input: &[Self], index: usize) -> Self { let packed_len = 128 * width / size_of::(); debug_assert_eq!(input.len(), packed_len, "Input buffer must be of size {}", packed_len); @@ -216,7 +219,6 @@ mod test { use core::array; use core::fmt::Debug; use core::mem::size_of; - use seq_macro::seq; use super::*;