From 5fdd25537c0e1f31ad855020e7b0cb8a7459be2e Mon Sep 17 00:00:00 2001 From: chesedo Date: Tue, 5 Nov 2024 14:56:58 +0200 Subject: [PATCH] feat(di): impl Clone for containers --- despatma-dependency-container/src/output.rs | 1 + .../expand/async-singleton-dependency.expanded.rs | 10 ++++++++++ .../tests/expand/async_dep.expanded.rs | 9 +++++++++ .../tests/expand/box_dyn_trait.expanded.rs | 9 +++++++++ .../tests/expand/box_dyn_trait_return_impl.expanded.rs | 9 +++++++++ .../tests/expand/documented.expanded.rs | 9 +++++++++ .../expand/impl_trait_registering_concrete.expanded.rs | 9 +++++++++ .../tests/expand/rpit.expanded.rs | 9 +++++++++ .../tests/expand/scoped-lifetime.expanded.rs | 10 ++++++++++ .../tests/expand/side-effects.expanded.rs | 10 ++++++++++ .../tests/expand/simple.expanded.rs | 9 +++++++++ .../tests/expand/simple_reference.expanded.rs | 9 +++++++++ .../singleton-lifetime-impl-trait-with-box.expanded.rs | 10 ++++++++++ .../expand/singleton-lifetime-impl-trait.expanded.rs | 10 ++++++++++ .../tests/expand/singleton-lifetime.expanded.rs | 10 ++++++++++ .../tests/expand/trailing_comma.expanded.rs | 9 +++++++++ 16 files changed, 142 insertions(+) diff --git a/despatma-dependency-container/src/output.rs b/despatma-dependency-container/src/output.rs index 4e1c8fe..8dd575d 100644 --- a/despatma-dependency-container/src/output.rs +++ b/despatma-dependency-container/src/output.rs @@ -250,6 +250,7 @@ impl ToTokens for Container { tokens.extend(quote! { #(#attrs)* + #[derive(core::clone::Clone)] struct #self_ty <'a> { #fields _phantom: std::marker::PhantomData<&'a ()>, diff --git a/despatma-dependency-container/tests/expand/async-singleton-dependency.expanded.rs b/despatma-dependency-container/tests/expand/async-singleton-dependency.expanded.rs index 232aae9..5648594 100644 --- a/despatma-dependency-container/tests/expand/async-singleton-dependency.expanded.rs +++ b/despatma-dependency-container/tests/expand/async-singleton-dependency.expanded.rs @@ -18,6 +18,16 @@ struct DependencyContainer<'a> { config: std::sync::Arc>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + config: ::core::clone::Clone::clone(&self.config), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/async_dep.expanded.rs b/despatma-dependency-container/tests/expand/async_dep.expanded.rs index 7f47053..66f133a 100644 --- a/despatma-dependency-container/tests/expand/async_dep.expanded.rs +++ b/despatma-dependency-container/tests/expand/async_dep.expanded.rs @@ -15,6 +15,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/box_dyn_trait.expanded.rs b/despatma-dependency-container/tests/expand/box_dyn_trait.expanded.rs index 2b8d9ab..9c5a4c3 100644 --- a/despatma-dependency-container/tests/expand/box_dyn_trait.expanded.rs +++ b/despatma-dependency-container/tests/expand/box_dyn_trait.expanded.rs @@ -27,6 +27,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/box_dyn_trait_return_impl.expanded.rs b/despatma-dependency-container/tests/expand/box_dyn_trait_return_impl.expanded.rs index dbfbe7a..25baa10 100644 --- a/despatma-dependency-container/tests/expand/box_dyn_trait_return_impl.expanded.rs +++ b/despatma-dependency-container/tests/expand/box_dyn_trait_return_impl.expanded.rs @@ -27,6 +27,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/documented.expanded.rs b/despatma-dependency-container/tests/expand/documented.expanded.rs index 8fcf39e..e990884 100644 --- a/despatma-dependency-container/tests/expand/documented.expanded.rs +++ b/despatma-dependency-container/tests/expand/documented.expanded.rs @@ -11,6 +11,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/impl_trait_registering_concrete.expanded.rs b/despatma-dependency-container/tests/expand/impl_trait_registering_concrete.expanded.rs index a41d7c8..8e58edb 100644 --- a/despatma-dependency-container/tests/expand/impl_trait_registering_concrete.expanded.rs +++ b/despatma-dependency-container/tests/expand/impl_trait_registering_concrete.expanded.rs @@ -23,6 +23,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/rpit.expanded.rs b/despatma-dependency-container/tests/expand/rpit.expanded.rs index 00c128b..295ef0d 100644 --- a/despatma-dependency-container/tests/expand/rpit.expanded.rs +++ b/despatma-dependency-container/tests/expand/rpit.expanded.rs @@ -20,6 +20,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/scoped-lifetime.expanded.rs b/despatma-dependency-container/tests/expand/scoped-lifetime.expanded.rs index 89d9f0e..db65db4 100644 --- a/despatma-dependency-container/tests/expand/scoped-lifetime.expanded.rs +++ b/despatma-dependency-container/tests/expand/scoped-lifetime.expanded.rs @@ -16,6 +16,16 @@ struct DependencyContainer<'a> { config: std::rc::Rc>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + config: ::core::clone::Clone::clone(&self.config), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/side-effects.expanded.rs b/despatma-dependency-container/tests/expand/side-effects.expanded.rs index 13fc394..5c8f48b 100644 --- a/despatma-dependency-container/tests/expand/side-effects.expanded.rs +++ b/despatma-dependency-container/tests/expand/side-effects.expanded.rs @@ -16,6 +16,16 @@ struct DependencyContainer<'a> { _tracing: std::rc::Rc>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _tracing: ::core::clone::Clone::clone(&self._tracing), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/simple.expanded.rs b/despatma-dependency-container/tests/expand/simple.expanded.rs index f0f91aa..be2be88 100644 --- a/despatma-dependency-container/tests/expand/simple.expanded.rs +++ b/despatma-dependency-container/tests/expand/simple.expanded.rs @@ -13,6 +13,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/simple_reference.expanded.rs b/despatma-dependency-container/tests/expand/simple_reference.expanded.rs index 8d792e7..56d6445 100644 --- a/despatma-dependency-container/tests/expand/simple_reference.expanded.rs +++ b/despatma-dependency-container/tests/expand/simple_reference.expanded.rs @@ -13,6 +13,15 @@ impl Task { struct Dependencies<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for Dependencies<'a> { + #[inline] + fn clone(&self) -> Dependencies<'a> { + Dependencies { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> Dependencies<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait-with-box.expanded.rs b/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait-with-box.expanded.rs index 8b64d65..ae6e8b7 100644 --- a/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait-with-box.expanded.rs +++ b/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait-with-box.expanded.rs @@ -34,6 +34,16 @@ struct DependencyContainer<'a> { dal: std::rc::Rc>>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + dal: ::core::clone::Clone::clone(&self.dal), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait.expanded.rs b/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait.expanded.rs index c47284c..d078c2b 100644 --- a/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait.expanded.rs +++ b/despatma-dependency-container/tests/expand/singleton-lifetime-impl-trait.expanded.rs @@ -27,6 +27,16 @@ struct DependencyContainer<'a> { dal: std::rc::Rc>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + dal: ::core::clone::Clone::clone(&self.dal), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/singleton-lifetime.expanded.rs b/despatma-dependency-container/tests/expand/singleton-lifetime.expanded.rs index 1c10337..ebc5665 100644 --- a/despatma-dependency-container/tests/expand/singleton-lifetime.expanded.rs +++ b/despatma-dependency-container/tests/expand/singleton-lifetime.expanded.rs @@ -16,6 +16,16 @@ struct DependencyContainer<'a> { config: std::rc::Rc>, _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + config: ::core::clone::Clone::clone(&self.config), + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self { diff --git a/despatma-dependency-container/tests/expand/trailing_comma.expanded.rs b/despatma-dependency-container/tests/expand/trailing_comma.expanded.rs index 89f5abf..067fbf6 100644 --- a/despatma-dependency-container/tests/expand/trailing_comma.expanded.rs +++ b/despatma-dependency-container/tests/expand/trailing_comma.expanded.rs @@ -17,6 +17,15 @@ impl Service { struct DependencyContainer<'a> { _phantom: std::marker::PhantomData<&'a ()>, } +#[automatically_derived] +impl<'a> ::core::clone::Clone for DependencyContainer<'a> { + #[inline] + fn clone(&self) -> DependencyContainer<'a> { + DependencyContainer { + _phantom: ::core::clone::Clone::clone(&self._phantom), + } + } +} impl<'a> DependencyContainer<'a> { pub fn new() -> Self { Self {