Skip to content

Commit

Permalink
Auto merge of #544 - kbknapp:issue-543, r=kbknapp
Browse files Browse the repository at this point in the history
imp(arg_enum!): allows using meta items like repr(C) with arg_enum!s

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
homu committed Jun 28, 2016
2 parents 18237f4 + edf9b23 commit 3d5d865
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 3d5d865

Please sign in to comment.