faster with less convenience

This commit is contained in:
Quaternions 2024-08-26 15:57:02 -07:00
parent 8206e16952
commit da5decb2f7

View File

@ -29,16 +29,13 @@ impl<const CHUNKS:usize,Frac> PartialEq for Fixed<CHUNKS,Frac>{
impl<const CHUNKS:usize,Frac> Eq for Fixed<CHUNKS,Frac>{}
macro_rules! impl_operator {
( $struct: ident, $trait: ident, $method: ident, $output: ty ) => {
impl<const CHUNKS:usize,Frac,T> core::ops::$trait<T> for $struct<CHUNKS,Frac>
where
$struct<CHUNKS,Frac>:From<T>
{
( $struct: ident, $trait: ident, $method: ident, $output: ty ) => {
impl<const CHUNKS:usize,Frac> core::ops::$trait<$struct<CHUNKS,Frac>> for $struct<CHUNKS,Frac>{
type Output = $output;
fn $method(self, other: T) -> Self::Output {
fn $method(self, other: Self) -> Self::Output {
Self {
bits:self.bits.$method($struct::<CHUNKS,Frac>::from(other).bits),
bits:self.bits.$method(other.bits),
frac:PhantomData,
}
}
@ -47,12 +44,9 @@ macro_rules! impl_operator {
}
macro_rules! impl_assign_operator {
( $struct: ident, $trait: ident, $method: ident ) => {
impl<const CHUNKS:usize,Frac,T> core::ops::$trait<T> for $struct<CHUNKS,Frac>
where
$struct<CHUNKS,Frac>:From<T>
{
fn $method(&mut self, other: T) {
self.bits.$method($struct::<CHUNKS,Frac>::from(other).bits);
impl<const CHUNKS:usize,Frac> core::ops::$trait<$struct<CHUNKS,Frac>> for $struct<CHUNKS,Frac>{
fn $method(&mut self, other: Self) {
self.bits.$method(other.bits);
}
}
};