The intent of `std::bitflags` is to allow building type-safe wrappers
around C-style flags APIs. But in addition to construction these flags
from the Rust side, we need a way to convert them from the C
side. This patch adds a `from_bits` function, which is unsafe since
the bits in question may not represent a valid combination of flags.
The `std::bitflags::bitflags!` macro did not provide support for
adding attributes to the generated structure or flags, due to
limitations in the parser for macros. This patch works around the
parser limitations by requiring a `flags` keyword in the overall
`bitflags!` invocation, and a `static` keyword for each flag:
bitflags!(
#[deriving(Hash)]
#[doc="Three flags"]
flags Flags: u32 {
#[doc="The first flag"]
static FlagA = 0x00000001,
static FlagB = 0x00000010,
static FlagC = 0x00000100
}
)