From 24fdd6987d29c0cf9642cbcd61c5cbd5954c58df Mon Sep 17 00:00:00 2001 From: rsk0315 Date: Sat, 10 Feb 2024 18:47:02 +0900 Subject: [PATCH] fix macros --- nekolib-src/ops/monoid/src/lib.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/nekolib-src/ops/monoid/src/lib.rs b/nekolib-src/ops/monoid/src/lib.rs index 75b630ef2e..e851bc4b22 100644 --- a/nekolib-src/ops/monoid/src/lib.rs +++ b/nekolib-src/ops/monoid/src/lib.rs @@ -45,7 +45,7 @@ impl 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 ($($gen,)*)>) where $($where)*; @@ -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) @@ -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) @@ -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) @@ -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)*) } )* }; @@ -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)*) } )* };