add clone

This commit is contained in:
Aiden McClelland
2021-04-28 16:09:55 -06:00
committed by Aiden McClelland
parent b70f1ce3af
commit e898d4d7ee
2 changed files with 60 additions and 8 deletions

View File

@@ -149,8 +149,13 @@ fn build_model_struct(
syn::parse2(quote! { patch_db::Model::<#ty> }).unwrap()
};
return quote! {
#[derive(Debug, Clone)]
#[derive(Debug)]
#model_vis struct #model_name(#inner_model);
impl std::clone::Clone for #model_name {
fn clone(&self) -> Self {
#model_name(self.0.clone())
}
}
impl core::ops::Deref for #model_name {
type Target = #inner_model;
fn deref(&self) -> &Self::Target {
@@ -227,8 +232,13 @@ fn build_model_struct(
Fields::Unit => (),
}
quote! {
#[derive(Debug, Clone)]
#[derive(Debug)]
#model_vis struct #model_name(patch_db::Model<#base_name>);
impl std::clone::Clone for #model_name {
fn clone(&self) -> Self {
#model_name(self.0.clone())
}
}
impl core::ops::Deref for #model_name {
type Target = patch_db::Model<#base_name>;
fn deref(&self) -> &Self::Target {