mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 17:18:50 +00:00
fix(ecs): some replacement issues
This commit is contained in:
parent
a01a52766d
commit
eced6ddf3f
8 changed files with 176 additions and 112 deletions
|
|
@ -27,6 +27,13 @@ pub fn component_derive(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
});
|
||||
|
||||
let clone_fields = fields.iter().map(|field| {
|
||||
let field_name = &field.ident;
|
||||
quote! {
|
||||
#field_name: self.#field_name.clone()
|
||||
}
|
||||
});
|
||||
|
||||
let default_fields = if let Data::Struct(data) = &input.data {
|
||||
match &data.fields {
|
||||
Fields::Named(fields) => fields
|
||||
|
|
@ -83,13 +90,11 @@ pub fn component_derive(input: TokenStream) -> TokenStream {
|
|||
impl Clone for #name {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
..*self
|
||||
#(#clone_fields),*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Copy for #name {}
|
||||
|
||||
impl std::fmt::Debug for #name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct(stringify!(#name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue