feat: allow dereferencing LocalResource to an AsyncDerived (see #4063) (#4077)

This commit is contained in:
Greg Johnston
2025-06-13 18:03:18 -04:00
committed by GitHub
parent 607a7987e5
commit c46b1c4e25

View File

@@ -20,7 +20,7 @@ use reactive_graph::{
};
use std::{
future::{pending, Future, IntoFuture},
ops::DerefMut,
ops::{Deref, DerefMut},
panic::Location,
};
@@ -43,6 +43,14 @@ impl<T> Clone for ArcLocalResource<T> {
}
}
impl<T> Deref for ArcLocalResource<T> {
type Target = ArcAsyncDerived<T>;
fn deref(&self) -> &Self::Target {
&self.data
}
}
impl<T> ArcLocalResource<T> {
/// Creates the resource.
///
@@ -269,6 +277,14 @@ pub struct LocalResource<T> {
defined_at: &'static Location<'static>,
}
impl<T> Deref for LocalResource<T> {
type Target = AsyncDerived<T>;
fn deref(&self) -> &Self::Target {
&self.data
}
}
impl<T> Clone for LocalResource<T> {
fn clone(&self) -> Self {
*self