| 5 | use synstructure::{AddBounds, BindStyle, Structure}; |
| 6 | |
| 7 | fn structure_with_prefix<'a>(input: &'a DeriveInput, prefix: &'static str) -> Result<Structure<'a>> { |
| 8 | let mut s = Structure::try_new(input)?; |
| 9 | s.add_bounds(AddBounds::None); |
| 10 | s.bind_with(|_| BindStyle::Move); |
| 11 | s.binding_name(move |field, i| match &field.ident { |
| 12 | Some(name) => format_ident!("{prefix}_{name}"), |
| 13 | None => format_ident!("{prefix}{i}"), |
| 14 | }); |
| 15 | Ok(s) |
| 16 | } |
| 17 | |
| 18 | pub fn derive(input: DeriveInput) -> Result<TokenStream> { |
| 19 | if let Data::Struct(ref s) = input.data |