Remove enum_from_u32
.
It's a macro that just creates an enum with a `from_u32` method. It has two arms. One is unused and the other has a single use. This commit inlines that single use and removes the whole macro. This increases readability because we don't have two different macros interacting (`enum_from_u32` and `language_item_table`).
This commit is contained in:
parent
d3d01e1cd3
commit
58a06b6a99
3 changed files with 19 additions and 51 deletions
|
@ -62,7 +62,6 @@ pub mod fx;
|
|||
pub mod graph;
|
||||
pub mod intern;
|
||||
pub mod jobserver;
|
||||
pub mod macros;
|
||||
pub mod marker;
|
||||
pub mod memmap;
|
||||
pub mod obligation_forest;
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#[macro_export]
|
||||
macro_rules! enum_from_u32 {
|
||||
($(#[$attr:meta])* pub enum $name:ident {
|
||||
$($(#[$var_attr:meta])* $variant:ident = $e:expr,)*
|
||||
}) => {
|
||||
$(#[$attr])*
|
||||
pub enum $name {
|
||||
$($(#[$var_attr])* $variant = $e),*
|
||||
}
|
||||
|
||||
impl $name {
|
||||
pub fn from_u32(u: u32) -> Option<$name> {
|
||||
$(if u == $name::$variant as u32 {
|
||||
return Some($name::$variant)
|
||||
})*
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
($(#[$attr:meta])* pub enum $name:ident {
|
||||
$($(#[$var_attr:meta])* $variant:ident,)*
|
||||
}) => {
|
||||
$(#[$attr])*
|
||||
pub enum $name {
|
||||
$($(#[$var_attr])* $variant,)*
|
||||
}
|
||||
|
||||
impl $name {
|
||||
pub fn from_u32(u: u32) -> Option<$name> {
|
||||
$(if u == $name::$variant as u32 {
|
||||
return Some($name::$variant)
|
||||
})*
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue