use std::ops::Mul;
pub trait One: Mul<Output = Self> + Sized {
fn one() -> Self;
}
pub trait MulRecip {
type Output;
fn mul_recip(self) -> Self::Output;
}
pub trait MulAssoc: Mul<Output = Self> + Sized {}
pub trait MulComm: Mul<Output = Self> + Sized {}
macro_rules! impl_trait {
(
$( impl ($T:ty) for { $( $U:ty ),* } $S:tt )*
) => {
$( $( impl $T for $U $S )* )*
};
}
impl_trait! {
impl (One) for {i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize} {
fn one() -> Self { 1 }
}
impl (MulAssoc) for {i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize} {}
impl (MulComm) for {i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize} {}
}