Guest User

Untitled

a guest
Jun 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #[macro_use]
  2. extern crate bitflags;
  3. #[macro_use]
  4. extern crate serde_derive;
  5. extern crate serde;
  6. extern crate serde_json;
  7.  
  8.  
  9. bitflags! {
  10. //this cfg applied to BF not to serialize, remove `not` to check
  11. #[cfg_attr(not(windows), derive(Serialize))]
  12. pub struct BF: i32 {
  13. const NONE = 0;
  14. const SOME = 1;
  15. }
  16. }
  17.  
  18. #[derive(Serialize)]
  19. struct V {
  20. bf: BF,
  21. }
  22.  
  23. fn main() {
  24. let n = BF::NONE;
  25. println!("{:?}", n);
  26.  
  27. let v= V { bf: n };
  28. let s = serde_json::to_string(&v);
  29. println!("{:?}", s);
  30. }
Add Comment
Please, Sign In to add comment