faster with less convenience
This commit is contained in:
parent
8206e16952
commit
da5decb2f7
@ -29,16 +29,13 @@ impl<const CHUNKS:usize,Frac> PartialEq for Fixed<CHUNKS,Frac>{
|
|||||||
impl<const CHUNKS:usize,Frac> Eq for Fixed<CHUNKS,Frac>{}
|
impl<const CHUNKS:usize,Frac> Eq for Fixed<CHUNKS,Frac>{}
|
||||||
|
|
||||||
macro_rules! impl_operator {
|
macro_rules! impl_operator {
|
||||||
( $struct: ident, $trait: ident, $method: ident, $output: ty ) => {
|
( $struct: ident, $trait: ident, $method: ident, $output: ty ) => {
|
||||||
impl<const CHUNKS:usize,Frac,T> core::ops::$trait<T> for $struct<CHUNKS,Frac>
|
impl<const CHUNKS:usize,Frac> core::ops::$trait<$struct<CHUNKS,Frac>> for $struct<CHUNKS,Frac>{
|
||||||
where
|
|
||||||
$struct<CHUNKS,Frac>:From<T>
|
|
||||||
{
|
|
||||||
type Output = $output;
|
type Output = $output;
|
||||||
|
|
||||||
fn $method(self, other: T) -> Self::Output {
|
fn $method(self, other: Self) -> Self::Output {
|
||||||
Self {
|
Self {
|
||||||
bits:self.bits.$method($struct::<CHUNKS,Frac>::from(other).bits),
|
bits:self.bits.$method(other.bits),
|
||||||
frac:PhantomData,
|
frac:PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,12 +44,9 @@ macro_rules! impl_operator {
|
|||||||
}
|
}
|
||||||
macro_rules! impl_assign_operator {
|
macro_rules! impl_assign_operator {
|
||||||
( $struct: ident, $trait: ident, $method: ident ) => {
|
( $struct: ident, $trait: ident, $method: ident ) => {
|
||||||
impl<const CHUNKS:usize,Frac,T> core::ops::$trait<T> for $struct<CHUNKS,Frac>
|
impl<const CHUNKS:usize,Frac> core::ops::$trait<$struct<CHUNKS,Frac>> for $struct<CHUNKS,Frac>{
|
||||||
where
|
fn $method(&mut self, other: Self) {
|
||||||
$struct<CHUNKS,Frac>:From<T>
|
self.bits.$method(other.bits);
|
||||||
{
|
|
||||||
fn $method(&mut self, other: T) {
|
|
||||||
self.bits.$method($struct::<CHUNKS,Frac>::from(other).bits);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user