Guest User

Untitled

a guest
Jun 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #![feature(trace_macros)]
  2. trace_macros!(true);
  3.  
  4. macro_rules! new_struct {
  5. ($name:ident, $($type:ty),*) => {
  6. struct $name {
  7. $(
  8. $type: $type
  9. ),*
  10. }
  11.  
  12. }
  13. }
  14.  
  15. struct FieldA;
  16. struct FieldB;
  17.  
  18. new_struct!(Struct, FieldA, FieldB);
  19.  
  20. /*
  21. Desired Output:
  22. struct Struct {
  23. field_a: FieldA,
  24. field_b: FieldB,
  25. }
  26. */
  27.  
  28.  
  29. fn main() {
  30.  
  31. }
Add Comment
Please, Sign In to add comment