Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_use]
- extern crate bitflags;
- #[macro_use]
- extern crate serde_derive;
- extern crate serde;
- extern crate serde_json;
- bitflags! {
- //this cfg applied to BF not to serialize, remove `not` to check
- #[cfg_attr(not(windows), derive(Serialize))]
- pub struct BF: i32 {
- const NONE = 0;
- const SOME = 1;
- }
- }
- #[derive(Serialize)]
- struct V {
- bf: BF,
- }
- fn main() {
- let n = BF::NONE;
- println!("{:?}", n);
- let v= V { bf: n };
- let s = serde_json::to_string(&v);
- println!("{:?}", s);
- }
Add Comment
Please, Sign In to add comment