card_est_array/traits/mod.rs
1/*
2 * SPDX-FileCopyrightText: 2024 Matteo Dell'Acqua
3 * SPDX-FileCopyrightText: 2025 Sebastiano Vigna
4 *
5 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
6 */
7
8mod estimator;
9pub use estimator::*;
10mod estimator_array;
11pub use estimator_array::*;
12
13use num_primitive::PrimitiveUnsigned;
14
15/// A convenience trait bundling the bounds required for word types used as
16/// backends for estimators, plus constants for zero and one (which avoid a
17/// dependence from the [`num-traits`](https://crates.io/crates/num-traits)
18/// crate).
19pub trait Word: PrimitiveUnsigned {
20 const ZERO: Self;
21 const ONE: Self;
22}
23
24macro_rules! impl_word {
25 ($($ty:ty),*) => {
26 $(impl Word for $ty {
27 const ZERO: Self = 0;
28 const ONE: Self = 1;
29 })*
30 };
31}
32
33impl_word!(u8, u16, u32, u64, u128, usize);