feat: use arc instead
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 13:58:13 +02:00
parent 10a56ad690
commit af57ef6cc8
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394

View File

@ -1,4 +1,4 @@
use std::rc::Rc;
use std::sync::Arc;
pub trait Component {
fn name(&self) -> String;
@ -27,11 +27,11 @@ pub trait Component {
#[derive(Clone)]
pub struct ConcreteComponent {
inner: Rc<dyn Component + 'static>,
inner: Arc<dyn Component + 'static>,
}
impl std::ops::Deref for ConcreteComponent {
type Target = Rc<dyn Component + 'static>;
type Target = Arc<dyn Component + 'static>;
fn deref(&self) -> &Self::Target {
&self.inner
@ -40,7 +40,7 @@ impl std::ops::Deref for ConcreteComponent {
impl ConcreteComponent {
pub fn new<T: Component + 'static>(t: T) -> Self {
Self { inner: Rc::new(t) }
Self { inner: Arc::new(t) }
}
}