#[allow(clippy::declare_interior_mutable_const)]
pub trait Zero {
const ZERO: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait One {
const ONE: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait Two {
const TWO: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait NegativeOne {
const NEGATIVE_ONE: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait OneHalf {
const ONE_HALF: Self;
}
pub trait Iverson {
fn iverson(b: bool) -> Self;
}
impl<T: One + Sized + Zero> Iverson for T {
#[inline]
fn iverson(b: bool) -> T {
if b {
T::ONE
} else {
T::ZERO
}
}
}