Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macro_rules! anonymous {
- {
- $($field_name:ident : $field_expr:expr),+
- } => {
- {
- #[allow(non_camel_case_types)]
- #[derive(Debug)] // Can add more derives here if wanted
- struct r#struct<$($field_name),+> {
- $($field_name: $field_name),+
- }
- r#struct {
- $($field_name: $field_expr),+
- }
- }
- };
- {
- $($field_name:ident : $field_expr:expr),+,
- } => {
- anonymous! { $($field_name : $field_expr),+ }
- }
- }
- struct r#struct {
- z: u32
- }
- fn main() {
- let y = anonymous! { x: r#struct { z: 0u32 } };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement