Skip to content

Commit

Permalink
better clone constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nertsal committed Nov 15, 2024
1 parent cbe4356 commit de7873c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/stecs-derive/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,19 @@ This struct is a version of [`{struct_name}`] that holds each field in its own [
// impl Clone for StructOf
let struct_of_clone = {
#[cfg(not(feature = "dynamic"))]
let dynamic = quote! {};
let (dynamic, dynamic_constraint) = (quote! {}, quote! {});
#[cfg(feature = "dynamic")]
let dynamic = quote! { r#dyn: self.r#dyn.clone(), };
let (dynamic, dynamic_constraint) = (
quote! { r#dyn: self.r#dyn.clone(), },
quote! { ::stecs::dynamic::DynamicStorage<#generic_family_name>: ::std::clone::Clone, },
);

quote! {
impl<#generics_family> ::std::clone::Clone for #struct_of_name<#generics_family_use>
where
#generic_family_name::Generator: ::std::clone::Clone,
#struct_split_name<#generics_family_use>: ::std::clone::Clone
#struct_split_name<#generics_family_use>: ::std::clone::Clone,
#dynamic_constraint
{
fn clone(&self) -> Self {
Self {
Expand Down

0 comments on commit de7873c

Please sign in to comment.