types: slightly simplify DivRev trait

This commit is contained in:
Matthias Schiffer 2023-02-12 21:01:28 +01:00
parent c34f531546
commit 5ee114ed0a
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -105,11 +105,12 @@ impl<T> IndexMut<ChunkCoords> for ChunkArray<T> {
} }
} }
pub trait DivRem<Rhs> { pub trait DivRem<Rhs>
type DivOutput; where
type RemOutput; Self: Div<Rhs>,
Self: Rem<Rhs>,
fn div_rem(self, rhs: Rhs) -> (Self::DivOutput, Self::RemOutput); {
fn div_rem(self, rhs: Rhs) -> (<Self as Div<Rhs>>::Output, <Self as Rem<Rhs>>::Output);
} }
impl<Lhs, Rhs> DivRem<Rhs> for Lhs impl<Lhs, Rhs> DivRem<Rhs> for Lhs
@ -119,10 +120,7 @@ where
Self: Copy, Self: Copy,
Rhs: Copy, Rhs: Copy,
{ {
type DivOutput = <Self as Div<Rhs>>::Output; fn div_rem(self, rhs: Rhs) -> (<Self as Div<Rhs>>::Output, <Self as Rem<Rhs>>::Output) {
type RemOutput = <Self as Rem<Rhs>>::Output;
fn div_rem(self, rhs: Rhs) -> (Self::DivOutput, Self::RemOutput) {
(self / rhs, self % rhs) (self / rhs, self % rhs)
} }
} }