summaryrefslogtreecommitdiff
path: root/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros.rs')
-rw-r--r--src/macros.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/macros.rs b/src/macros.rs
index f14bbf5522..378da7ccfb 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -121,6 +121,36 @@ macro_rules! s_no_extra_traits {
);
}
+#[allow(unused_macros)]
+macro_rules! e {
+ ($($(#[$attr:meta])* pub enum $i:ident { $($field:tt)* })*) => ($(
+ __item! {
+ #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
+ $(#[$attr])*
+ pub enum $i { $($field)* }
+ }
+ impl ::Copy for $i {}
+ impl ::Clone for $i {
+ fn clone(&self) -> $i { *self }
+ }
+ )*);
+}
+
+#[allow(unused_macros)]
+macro_rules! s_paren {
+ ($($(#[$attr:meta])* pub struct $i:ident ( $($field:tt)* ); )* ) => ($(
+ __item! {
+ #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
+ $(#[$attr])*
+ pub struct $i ( $($field)* );
+ }
+ impl ::Copy for $i {}
+ impl ::Clone for $i {
+ fn clone(&self) -> $i { *self }
+ }
+ )*);
+}
+
// This is a pretty horrible hack to allow us to conditionally mark
// some functions as 'const', without requiring users of this macro
// to care about the "const-extern-fn" feature.