Skip to content

Commit

Permalink
feat(di): impl Clone for containers
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Nov 5, 2024
1 parent 710d113 commit 5fdd255
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions despatma-dependency-container/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ struct DependencyContainer<'a> {
config: std::sync::Arc<async_once_cell::OnceCell<Config>>,
_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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ impl<D: DAL> Service<D> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ impl<D: DAL> Service<D> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ impl<D: DAL> Service<D> {
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 {
Expand Down
9 changes: 9 additions & 0 deletions despatma-dependency-container/tests/expand/rpit.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ impl<D: DAL> Service<D> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ struct DependencyContainer<'a> {
config: std::rc::Rc<std::cell::OnceCell<Config>>,
_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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ struct DependencyContainer<'a> {
_tracing: std::rc::Rc<std::cell::OnceCell<()>>,
_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 {
Expand Down
9 changes: 9 additions & 0 deletions despatma-dependency-container/tests/expand/simple.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ struct DependencyContainer<'a> {
dal: std::rc::Rc<std::cell::OnceCell<Box<dyn DAL>>>,
_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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ struct DependencyContainer<'a> {
dal: std::rc::Rc<std::cell::OnceCell<PostgresDAL>>,
_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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ struct DependencyContainer<'a> {
config: std::rc::Rc<std::cell::OnceCell<Config>>,
_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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5fdd255

Please sign in to comment.