]> git.lizzy.rs Git - rust.git/commitdiff
Use {} for bitflags! definition and invocations
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Thu, 4 Sep 2014 06:35:06 +0000 (16:35 +1000)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Thu, 4 Sep 2014 17:33:00 +0000 (03:33 +1000)
This looks nicer because it reflects Rust's other syntactic structures.

src/libstd/bitflags.rs
src/libstd/io/mod.rs
src/libstd/lib.rs

index f540398fcaa94ab179851b2da91c1213ef7e28aa..3d1bc20cca49ecd0870bab4346977e0260b370b0 100644 (file)
@@ -22,7 +22,7 @@
 /// # Example
 ///
 /// ~~~rust
-/// bitflags!(
+/// bitflags! {
 ///     flags Flags: u32 {
 ///         static FlagA       = 0x00000001,
 ///         static FlagB       = 0x00000010,
@@ -31,7 +31,7 @@
 ///                            | FlagB.bits
 ///                            | FlagC.bits,
 ///     }
-/// )
+/// }
 ///
 /// fn main() {
 ///     let e1 = FlagA | FlagC;
 /// ~~~rust
 /// use std::fmt;
 ///
-/// bitflags!(
+/// bitflags! {
 ///     flags Flags: u32 {
 ///         static FlagA   = 0x00000001,
 ///         static FlagB   = 0x00000010,
 ///     }
-/// )
+/// }
 ///
 /// impl Flags {
 ///     pub fn clear(&mut self) {
 /// - `insert`: inserts the specified flags in-place
 /// - `remove`: removes the specified flags in-place
 #[macro_export]
-macro_rules! bitflags(
+macro_rules! bitflags {
     ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
         $($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+
-    }) => (
+    }) => {
         #[deriving(PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
         $(#[$attr])*
         pub struct $BitFlags {
@@ -216,18 +216,18 @@ fn not(&self) -> $BitFlags {
                 $BitFlags { bits: !self.bits } & $BitFlags::all()
             }
         }
-    );
+    };
     ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
         $($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+,
-    }) => (
-        bitflags!(
+    }) => {
+        bitflags! {
             $(#[$attr])*
             flags $BitFlags: u32 {
                 $($(#[$Flag_attr])* static $Flag = $value),+
             }
-        )
-    );
-)
+        }
+    };
+}
 
 #[cfg(test)]
 mod tests {
@@ -235,7 +235,7 @@ mod tests {
     use option::{Some, None};
     use ops::{BitOr, BitAnd, Sub, Not};
 
-    bitflags!(
+    bitflags! {
         #[doc = "> The first principle is that you must not fool yourself — and"]
         #[doc = "> you are the easiest person to fool."]
         #[doc = "> "]
@@ -252,7 +252,7 @@ mod tests {
                                | FlagB.bits
                                | FlagC.bits,
         }
-    )
+    }
 
     #[test]
     fn test_bits(){
index c7996c549f474fb7dbaa1f3b3af7178552e51fc3..804d6c79d23d0763a12083db8f7c85d11a1d7bad 100644 (file)
@@ -1794,9 +1794,9 @@ pub struct UnstableFileStat {
     pub gen: u64,
 }
 
-bitflags!(
-    #[doc="A set of permissions for a file or directory is represented
-by a set of flags which are or'd together."]
+bitflags! {
+    #[doc = "A set of permissions for a file or directory is represented"]
+    #[doc = "by a set of flags which are or'd together."]
     flags FilePermission: u32 {
         static UserRead     = 0o400,
         static UserWrite    = 0o200,
@@ -1812,23 +1812,23 @@ pub struct UnstableFileStat {
         static GroupRWX = GroupRead.bits | GroupWrite.bits | GroupExecute.bits,
         static OtherRWX = OtherRead.bits | OtherWrite.bits | OtherExecute.bits,
 
-        #[doc="Permissions for user owned files, equivalent to 0644 on
-unix-like systems."]
+        #[doc = "Permissions for user owned files, equivalent to 0644 on"]
+        #[doc = "unix-like systems."]
         static UserFile = UserRead.bits | UserWrite.bits | GroupRead.bits | OtherRead.bits,
 
-        #[doc="Permissions for user owned directories, equivalent to 0755 on
-unix-like systems."]
+        #[doc = "Permissions for user owned directories, equivalent to 0755 on"]
+        #[doc = "unix-like systems."]
         static UserDir  = UserRWX.bits | GroupRead.bits | GroupExecute.bits |
                    OtherRead.bits | OtherExecute.bits,
 
-        #[doc="Permissions for user owned executables, equivalent to 0755
-on unix-like systems."]
+        #[doc = "Permissions for user owned executables, equivalent to 0755"]
+        #[doc = "on unix-like systems."]
         static UserExec = UserDir.bits,
 
-        #[doc="All possible permissions enabled."]
-        static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits
+        #[doc = "All possible permissions enabled."]
+        static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits,
     }
-)
+}
 
 impl Default for FilePermission {
     #[inline]
index 7fed4c94164b6b75c07be6aa3f4c18093061955a..443b5713665b920dca2df1671bb25cf6f1ef7812 100644 (file)
@@ -281,7 +281,7 @@ mod std {
     pub use fmt; // used for any formatting strings
     pub use io; // used for println!()
     pub use local_data; // used for local_data_key!()
-    pub use option; // used for bitflags!()
+    pub use option; // used for bitflags!{}
     pub use rt; // used for fail!()
     pub use vec; // used for vec![]