Nested Struct
Ever wanted to be able to create a data structure that contains nested data? Do you find yourself creating many individual structs simply to combine them together? Well, this is the library for you!
Transform this
Into this
use *;
nested_struct!
}
Basic usage
Creates a new struct that may feature nested fields.
use *;
nested_struct!
}
let _ = MyStruct ;
Deeply-nested structs
Nesting is not limited to a single level. You can generate structs with multi-nested fields:
use *;
nested_struct!
}
}
let _ = MyStruct ;
Applying field attributes to fields that are nested structs
Like with a normal struct, nested fields can have attributes placed on them:
use *;
nested_struct!
}
Applying struct-level attributes to nested structs
If you want to apply attributes on the generated, nested struct, you need to
use the @nested
marker. This can be used multiple times, but must occur AFTER
any field-specific attributes:
use *;
nested_struct!
}
let nested_field = NestedField ;
let _ = MyStruct ;
License
This project is licensed under either of
Apache License, Version 2.0, (LICENSE-APACHE or apache-license) MIT license (LICENSE-MIT or mit-license) at your option.