feat: add send
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-05-25 14:03:00 +02:00
parent af57ef6cc8
commit 843139591c
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394

View File

@ -27,11 +27,11 @@ pub trait Component {
#[derive(Clone)] #[derive(Clone)]
pub struct ConcreteComponent { pub struct ConcreteComponent {
inner: Arc<dyn Component + 'static>, inner: Arc<dyn Component + Send + 'static>,
} }
impl std::ops::Deref for ConcreteComponent { impl std::ops::Deref for ConcreteComponent {
type Target = Arc<dyn Component + 'static>; type Target = Arc<dyn Component + Send + 'static>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.inner &self.inner
@ -39,7 +39,7 @@ impl std::ops::Deref for ConcreteComponent {
} }
impl ConcreteComponent { impl ConcreteComponent {
pub fn new<T: Component + 'static>(t: T) -> Self { pub fn new<T: Component + Send + 'static>(t: T) -> Self {
Self { inner: Arc::new(t) } Self { inner: Arc::new(t) }
} }
} }
@ -54,7 +54,7 @@ impl IntoComponent for ConcreteComponent {
} }
} }
impl<T: Component + 'static> IntoComponent for T { impl<T: Component + Send + 'static> IntoComponent for T {
fn into_component(self) -> ConcreteComponent { fn into_component(self) -> ConcreteComponent {
ConcreteComponent::new(self) ConcreteComponent::new(self)
} }