use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
pub fn packed_layout_derive(mut s: synstructure::Structure) -> TokenStream2 {
s.bind_with(|_| synstructure::BindStyle::Move)
.add_bounds(synstructure::AddBounds::Generics)
.underscore_const(true);
let pull_body = s.each(|binding| {
quote! { ::pro_storage::traits::PackedLayout::pull_packed(#binding, __key); }
});
let push_body = s.each(|binding| {
quote! { ::pro_storage::traits::PackedLayout::push_packed(#binding, __key); }
});
let clear_body = s.each(|binding| {
quote! { ::pro_storage::traits::PackedLayout::clear_packed(#binding, __key); }
});
s.gen_impl(quote! {
gen impl ::pro_storage::traits::PackedLayout for @Self {
fn pull_packed(&mut self, __key: &::pro_primitives::Key) {
match self { #pull_body }
}
fn push_packed(&self, __key: &::pro_primitives::Key) {
match self { #push_body }
}
fn clear_packed(&self, __key: &::pro_primitives::Key) {
match self { #clear_body }
}
}
})
}