Skip to content

Commit

Permalink
Simplified the Lcm and Gcd impl macros
Browse files Browse the repository at this point in the history
  • Loading branch information
1Git2Clone committed Nov 17, 2024
1 parent 27cd6e0 commit efdedcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/utils/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ where
}
}

macro_rules! auto_impl_gcd {
($($x:ty),+ $(,)?) => ($(
impl $crate::utils::gcd::Gcd for $x {}
macro_rules! gcd_impl {
($name:ident for $($x:ty)*) => ($(
impl $name for $x {}
)*)
}

auto_impl_gcd!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);
gcd_impl!(Gcd for i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize);
8 changes: 4 additions & 4 deletions src/utils/lcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub trait Lcm: Gcd {
}
}

macro_rules! auto_impl_lcm {
($($x:ty),+ $(,)?) => ($(
impl $crate::utils::lcm::Lcm for $x {}
macro_rules! lcm_impl {
($name:ident for $($x:ty)*) => ($(
impl $name for $x {}
)*)
}

auto_impl_lcm!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);
lcm_impl!(Lcm for i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize);

0 comments on commit efdedcf

Please sign in to comment.