use super::*;
pub trait CanPow<const E: i32>: Unit {
type Output: Unit;
fn pow(self) -> Self::Output;
}
pub trait CanSquare: Unit {
type Output: Unit;
fn squared(self) -> Self::Output;
}
impl<U: CanPow<2>> CanSquare for U {
type Output = U::Output;
fn squared(self) -> Self::Output { self.pow() }
}
pub trait CanCube: Unit {
type Output: Unit;
fn cubed(self) -> Self::Output;
}
impl<U: CanPow<3>> CanCube for U {
type Output = U::Output;
fn cubed(self) -> Self::Output { self.pow() }
}
pub trait CanRoot<const D: i32>: Unit {
type Output: Unit;
fn root(self) -> Self::Output;
}
pub trait CanSquareRoot: Unit {
type Output: Unit;
fn sqrt(self) -> Self::Output;
}
impl<U: CanRoot<2>> CanSquareRoot for U {
type Output = U::Output;
fn sqrt(self) -> Self::Output { self.root() }
}
pub trait CanCubeRoot: Unit {
type Output: Unit;
fn cbrt(self) -> Self::Output;
}
impl<U: CanRoot<3>> CanCubeRoot for U {
type Output = U::Output;
fn cbrt(self) -> Self::Output { self.root() }
}