Skip to content

Commit

Permalink
fix macros
Browse files Browse the repository at this point in the history
  • Loading branch information
rsk0315 committed Feb 10, 2024
1 parent 72d501a commit 24fdd69
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions nekolib-src/ops/monoid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<T: BinaryOp + Associative + Identity + Recip + Commutative>
macro_rules! def_monoid_generics {
(
$name:ident[$($gen:tt)*] where [$($where:tt)*] =
($ty:ty, $op:expr, $id:expr)
($ty:ty, $op:expr, $id:expr $(,)?)
) => {
struct $name<$($gen)*>(std::marker::PhantomData<fn() -> ($($gen,)*)>)
where $($where)*;
Expand Down Expand Up @@ -78,7 +78,7 @@ macro_rules! def_monoid_generics {
};
(
$name:ident[$($gen:tt)*] where [$($where:tt)*] =
($ty:ty, $op:expr, $id:expr, Commutative)
($ty:ty, $op:expr, $id:expr, Commutative $(,)?)
) => {
$crate::def_monoid_generics! {
$name[$($gen)*] where [$($where)*] = ($ty, $op, $id)
Expand All @@ -105,7 +105,7 @@ macro_rules! def_monoid_generics {
macro_rules! def_group_generics {
(
$name:ident[$($gen:tt)*] where [$($where:tt)*] =
($ty:ty, $op:expr, $id:expr, $recip:expr) $(,)?
($ty:ty, $op:expr, $id:expr, $recip:expr $(,)?)
) => {
$crate::def_monoid_generics! {
$name[$($gen)*] where [$($where)*] = ($ty, $op, $id)
Expand All @@ -118,7 +118,7 @@ macro_rules! def_group_generics {
};
(
$name:ident[$($gen:tt)*] where [$($where:tt)*] =
($ty:ty, $op:expr, $id:expr, $recip:expr, Commutative)
($ty:ty, $op:expr, $id:expr, $recip:expr, Commutative $(,)?)
) => {
$crate::def_group_generics! {
$name[$($gen)*] where [$($where)*] = ($ty, $op, $id, $recip)
Expand All @@ -143,9 +143,12 @@ macro_rules! def_group_generics {

#[macro_export]
macro_rules! def_monoid {
( $name:ident = ($ty:ty, $op:expr, $id:expr) ) => {
( $name:ident = ($ty:ty, $op:expr, $id:expr $(,)?) ) => {
$crate::def_monoid_generics! { $name[] where [] = ($ty, $op, $id) }
};
( $name:ident = ($ty:ty, $op:expr, $id:expr, Commutative $(,)?) ) => {
$crate::def_monoid_generics! { $name[] where [] = ($ty, $op, $id, Commutative) }
};
( $($name:ident = ($($impl:tt)*)),* ) => { $(
$crate::def_monoid! { $name = ($($impl)*) }
)* };
Expand All @@ -156,9 +159,12 @@ macro_rules! def_monoid {

#[macro_export]
macro_rules! def_group {
( $name:ident = ($ty:ty, $op:expr, $id:expr, $recip:expr) ) => {
( $name:ident = ($ty:ty, $op:expr, $id:expr, $recip:expr $(,)?) ) => {
$crate::def_group_generics! { $name[] where [] = ($ty, $op, $id, $recip) }
};
( $name:ident = ($ty:ty, $op:expr, $id:expr, $recip:expr, Commutative $(,)?) ) => {
$crate::def_group_generics! { $name[] where [] = ($ty, $op, $id, $recip, Commutative) }
};
( $($name:ident = ($($impl:tt)*)),* ) => { $(
$crate::def_group! { $name = ($($impl)*) }
)* };
Expand Down

0 comments on commit 24fdd69

Please sign in to comment.