Skip to content

Commit

Permalink
Allow trailing commas in bitflags! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanzab committed Sep 4, 2014
1 parent 4a5a9c5 commit f3f038c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/libstd/bitflags.rs
Expand Up @@ -24,7 +24,7 @@
//! static FlagC = 0x00000100,
//! static FlagABC = FlagA.bits
//! | FlagB.bits
//! | FlagC.bits
//! | FlagC.bits,
//! }
//! )
//!
Expand All @@ -46,7 +46,7 @@
//! bitflags!(
//! flags Flags: u32 {
//! static FlagA = 0x00000001,
//! static FlagB = 0x00000010
//! static FlagB = 0x00000010,
//! }
//! )
//!
Expand Down Expand Up @@ -215,7 +215,17 @@ macro_rules! bitflags(
$BitFlags { bits: !self.bits } & $BitFlags::all()
}
}
)
);
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
$($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+,
}) => (
bitflags!(
$(#[$attr])*
flags $BitFlags: u32 {
$($(#[$Flag_attr])* static $Flag = $value),+
}
)
);
)

#[cfg(test)]
Expand All @@ -231,7 +241,7 @@ mod tests {
static FlagC = 0x00000100,
static FlagABC = FlagA.bits
| FlagB.bits
| FlagC.bits
| FlagC.bits,
}
)

Expand Down

0 comments on commit f3f038c

Please sign in to comment.