Skip to content

Commit

Permalink
imp(arg_enum!): allows using meta items like repr(C) with arg_enum!s
Browse files Browse the repository at this point in the history
One can now use more than one meta item, and things like `#[repr(C)]`

Example:

```rust

arg_enum! {
	#[repr(C)]
	#[derive(Debug)]
	pub enum MyEnum {
		A=1,
		B=2
	}
}

```

Closes #543
  • Loading branch information
kbknapp committed Jun 28, 2016
1 parent 18237f4 commit edf9b23
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,33 +334,33 @@ macro_rules! arg_enum {
}
});
};
(#[$($m:meta),+] pub enum $e:ident { $($v:ident),+ } ) => {
($(#[$($m:meta),+])+ pub enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
arg_enum!(@impls
(#[$($m),+]
($(#[$($m),+])+
pub enum $e {
$($v),+
$($v$(=$val)*),+
}) -> ($e, $($v),+)
);
};
(#[$($m:meta),+] enum $e:ident { $($v:ident),+ } ) => {
($(#[$($m:meta),+])+ enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
arg_enum!(@impls
(#[$($m),+]
($(#[$($m),+])+
enum $e {
$($v),+
$($v$(=$val)*),+
}) -> ($e, $($v),+)
);
};
(pub enum $e:ident { $($v:ident),+ } ) => {
(pub enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
arg_enum!(@impls
(pub enum $e {
$($v),+
$($v$(=$val)*),+
}) -> ($e, $($v),+)
);
};
(enum $e:ident { $($v:ident),+ } ) => {
(enum $e:ident { $($v:ident $(=$val:expr)*),+ } ) => {
arg_enum!(@impls
(enum $e {
$($v),+
$($v$(=$val)*),+
}) -> ($e, $($v),+)
);
};
Expand Down

0 comments on commit edf9b23

Please sign in to comment.