macro_rules! s2 {
($(
$(#$attr:tt)*
$pub:vis $t:ident $i:ident { $($field:tt)* }
)*) => { ... };
(it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => { ... };
(it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => { ... };
}Expand description
Like s, but (1) generates a Default impl for every struct in the block, and (2) adds a
private field to the struct to replicate the effects of the non_exhaustive attribute while
rust-lang/rust#132699 gets sorted out.
To opt out of having the private field added, annotate the struct with an exhaustive
attribute, as in:
ⓘ
s2! {
#[exhaustive]
struct Something {
...
}
}See [custom_struct] for details.