-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlib.rs
More file actions
55 lines (41 loc) · 1.14 KB
/
lib.rs
File metadata and controls
55 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*!
Custom derive attributes for types generated by [`bitflags`](https://docs.rs/bitflags).
## Usage
Add `bitflags-derive` to your `Cargo.toml` alongside `bitflags`:
```toml
[dependencies.bitflags-derive]
version = "0.0.1"
[dependencies.bitflags]
version = "2"
```
Inside the [`bitflags!` macro](https://docs.rs/bitflags/latest/bitflags/macro.bitflags.html), add a `#[derive]` attribute with any traits from `bitflags-derive` that you'd like to support:
```rust
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate bitflags_derive;
# fn main() -> Result<(), bitflags::parser::ParseError> {
bitflags! {
#[derive(FlagsDisplay, FlagsFromStr)]
struct MyFlags: u8 {
const A = 1;
const B = 1 << 1;
const C = 1 << 2;
}
}
let flags = "A | B".parse::<MyFlags>()?;
assert_eq!("A | B", flags.to_string());
# Ok(())
# }
```
These derives work for any type that implements the [`Flags`](https://docs.rs/bitflags/latest/bitflags/trait.Flags.html) trait.
*/
#![no_std]
#![deny(missing_docs)]
#[doc(inline)]
pub use bitflags_derive_macros::*;
#[doc(hidden)]
pub mod __private {
pub use bitflags;
pub use core;
}