Skip to content

Commit ef354d8

Browse files
committed
Use {} for bitflags! definition and invocations
This looks nicer because it reflects Rust's other syntactic structures.
1 parent ff72583 commit ef354d8

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

src/libstd/bitflags.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/// # Example
2323
///
2424
/// ~~~rust
25-
/// bitflags!(
25+
/// bitflags! {
2626
/// flags Flags: u32 {
2727
/// static FlagA = 0x00000001,
2828
/// static FlagB = 0x00000010,
@@ -31,7 +31,7 @@
3131
/// | FlagB.bits
3232
/// | FlagC.bits,
3333
/// }
34-
/// )
34+
/// }
3535
///
3636
/// fn main() {
3737
/// let e1 = FlagA | FlagC;
@@ -48,12 +48,12 @@
4848
/// ~~~rust
4949
/// use std::fmt;
5050
///
51-
/// bitflags!(
51+
/// bitflags! {
5252
/// flags Flags: u32 {
5353
/// static FlagA = 0x00000001,
5454
/// static FlagB = 0x00000010,
5555
/// }
56-
/// )
56+
/// }
5757
///
5858
/// impl Flags {
5959
/// pub fn clear(&mut self) {
@@ -110,10 +110,10 @@
110110
/// - `insert`: inserts the specified flags in-place
111111
/// - `remove`: removes the specified flags in-place
112112
#[macro_export]
113-
macro_rules! bitflags(
113+
macro_rules! bitflags {
114114
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
115115
$($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+
116-
}) => (
116+
}) => {
117117
#[deriving(PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
118118
$(#[$attr])*
119119
pub struct $BitFlags {
@@ -216,26 +216,26 @@ macro_rules! bitflags(
216216
$BitFlags { bits: !self.bits } & $BitFlags::all()
217217
}
218218
}
219-
);
219+
};
220220
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
221221
$($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+,
222-
}) => (
223-
bitflags!(
222+
}) => {
223+
bitflags! {
224224
$(#[$attr])*
225225
flags $BitFlags: u32 {
226226
$($(#[$Flag_attr])* static $Flag = $value),+
227227
}
228-
)
229-
);
230-
)
228+
}
229+
};
230+
}
231231

232232
#[cfg(test)]
233233
mod tests {
234234
use hash;
235235
use option::{Some, None};
236236
use ops::{BitOr, BitAnd, Sub, Not};
237237

238-
bitflags!(
238+
bitflags! {
239239
#[doc = "> The first principle is that you must not fool yourself — and"]
240240
#[doc = "> you are the easiest person to fool."]
241241
#[doc = "> "]
@@ -252,7 +252,7 @@ mod tests {
252252
| FlagB.bits
253253
| FlagC.bits,
254254
}
255-
)
255+
}
256256

257257
#[test]
258258
fn test_bits(){

src/libstd/io/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1794,9 +1794,9 @@ pub struct UnstableFileStat {
17941794
pub gen: u64,
17951795
}
17961796

1797-
bitflags!(
1798-
#[doc="A set of permissions for a file or directory is represented
1799-
by a set of flags which are or'd together."]
1797+
bitflags! {
1798+
#[doc = "A set of permissions for a file or directory is represented"]
1799+
#[doc = "by a set of flags which are or'd together."]
18001800
flags FilePermission: u32 {
18011801
static UserRead = 0o400,
18021802
static UserWrite = 0o200,
@@ -1812,23 +1812,23 @@ by a set of flags which are or'd together."]
18121812
static GroupRWX = GroupRead.bits | GroupWrite.bits | GroupExecute.bits,
18131813
static OtherRWX = OtherRead.bits | OtherWrite.bits | OtherExecute.bits,
18141814

1815-
#[doc="Permissions for user owned files, equivalent to 0644 on
1816-
unix-like systems."]
1815+
#[doc = "Permissions for user owned files, equivalent to 0644 on"]
1816+
#[doc = "unix-like systems."]
18171817
static UserFile = UserRead.bits | UserWrite.bits | GroupRead.bits | OtherRead.bits,
18181818

1819-
#[doc="Permissions for user owned directories, equivalent to 0755 on
1820-
unix-like systems."]
1819+
#[doc = "Permissions for user owned directories, equivalent to 0755 on"]
1820+
#[doc = "unix-like systems."]
18211821
static UserDir = UserRWX.bits | GroupRead.bits | GroupExecute.bits |
18221822
OtherRead.bits | OtherExecute.bits,
18231823

1824-
#[doc="Permissions for user owned executables, equivalent to 0755
1825-
on unix-like systems."]
1824+
#[doc = "Permissions for user owned executables, equivalent to 0755"]
1825+
#[doc = "on unix-like systems."]
18261826
static UserExec = UserDir.bits,
18271827

1828-
#[doc="All possible permissions enabled."]
1829-
static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits
1828+
#[doc = "All possible permissions enabled."]
1829+
static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits,
18301830
}
1831-
)
1831+
}
18321832

18331833
impl Default for FilePermission {
18341834
#[inline]

src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ mod std {
281281
pub use fmt; // used for any formatting strings
282282
pub use io; // used for println!()
283283
pub use local_data; // used for local_data_key!()
284-
pub use option; // used for bitflags!()
284+
pub use option; // used for bitflags!{}
285285
pub use rt; // used for fail!()
286286
pub use vec; // used for vec![]
287287

0 commit comments

Comments
 (0)