Checks that `unpacked` bytes are less than `N`. All of `unpacked` is assumed to be < `FACTOR`. `HISTOGRAM` must be 0.
(
unpacked: &[u8],
)
| 217 | /// Checks that `unpacked` bytes are less than `N`. All of `unpacked` is assumed to be < `FACTOR`. |
| 218 | /// `HISTOGRAM` must be 0. |
| 219 | fn check_less_than<const N: usize, const HISTOGRAM: usize, const FACTOR: usize>( |
| 220 | unpacked: &[u8], |
| 221 | ) -> Result<[usize; HISTOGRAM]> { |
| 222 | assert!(FACTOR >= N); |
| 223 | debug_assert!(unpacked.iter().all(|&v| (v as usize) < FACTOR)); |
| 224 | if FACTOR > N && unpacked.iter().copied().max().unwrap_or(0) as usize >= N { |
| 225 | return invalid_packing(); |
| 226 | } |
| 227 | Ok(std::array::from_fn(|_| unreachable!("HISTOGRAM not 0"))) |
| 228 | } |
| 229 | |
| 230 | /// Returns `Ok(histogram)` if buckets after `OUT` are 0. |
| 231 | fn check_histogram<const IN: usize, const OUT: usize>( |
nothing calls this directly
no test coverage detected