mirror of
https://github.com/Zenithsiz/dynatos.git
synced 2026-02-07 20:51:04 +00:00
Added #[track_caller] attribute to several signal functions.
This commit is contained in:
parent
5aef275f55
commit
d62e45e587
@ -91,6 +91,7 @@ impl<F: Future<Output = Result<T, E>> + 'static, T: 'static, E: Clone + 'static>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
let borrow = self.inner.borrow();
|
||||
match borrow {
|
||||
@ -106,6 +107,7 @@ impl<F: Future<Output = Result<T, E>> + 'static, T: 'static, E: Clone + 'static>
|
||||
impl<F: Future<Output = Result<T, E>> + 'static, T: 'static, E: Clone + 'static> SignalWith for LoadableSignal<F> {
|
||||
type Value<'a> = Loadable<&'a T, E>;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F2, O>(&self, f: F2) -> O
|
||||
where
|
||||
F2: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -142,6 +144,7 @@ impl<F: Future<Output = Result<T, E>>, T: 'static, E: Clone + 'static> SignalBor
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let borrow = self.inner.borrow_mut();
|
||||
match borrow {
|
||||
@ -161,6 +164,7 @@ where
|
||||
{
|
||||
type Value<'a> = Loadable<&'a mut T, E>;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F2, O>(&self, f: F2) -> O
|
||||
where
|
||||
F2: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -152,6 +152,7 @@ impl<F: Future> SignalBorrow for AsyncSignal<F> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
// Try to poll the future, if we don't have a value yet
|
||||
if self.inner.value.borrow().is_none() {
|
||||
@ -178,6 +179,7 @@ where
|
||||
{
|
||||
type Value<'a> = Option<&'a F::Output>;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F2, O>(&self, f: F2) -> O
|
||||
where
|
||||
F2: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -217,6 +219,7 @@ impl<F: Future> SignalBorrowMut for AsyncSignal<F> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let value = self.inner.value.borrow_mut();
|
||||
value.is_some().then(|| BorrowRefMut {
|
||||
@ -236,6 +239,7 @@ where
|
||||
{
|
||||
type Value<'a> = Option<&'a mut F::Output>;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F2, O>(&self, f: F2) -> O
|
||||
where
|
||||
F2: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -79,6 +79,7 @@ impl<T: 'static, F: ?Sized> SignalBorrow for Derived<T, F> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
let effect_fn = self.effect.inner_fn();
|
||||
let value = effect_fn.value.borrow();
|
||||
@ -89,6 +90,7 @@ impl<T: 'static, F: ?Sized> SignalBorrow for Derived<T, F> {
|
||||
impl<T: 'static, F: ?Sized> SignalWith for Derived<T, F> {
|
||||
type Value<'a> = &'a T;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F2, O>(&self, f: F2) -> O
|
||||
where
|
||||
F2: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -90,6 +90,7 @@ impl<T: ?Sized + 'static> SignalBorrow for Signal<T> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
if let Some(effect) = effect::running() {
|
||||
self.inner.trigger.add_subscriber(effect);
|
||||
@ -107,6 +108,7 @@ impl<T: ?Sized + 'static> SignalBorrow for Signal<T> {
|
||||
impl<T: ?Sized + 'static> SignalWith for Signal<T> {
|
||||
type Value<'a> = &'a T;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -165,6 +167,7 @@ impl<T: ?Sized + 'static> SignalBorrowMut for Signal<T> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let value = self
|
||||
.inner
|
||||
@ -182,6 +185,7 @@ impl<T: ?Sized + 'static> SignalBorrowMut for Signal<T> {
|
||||
impl<T: ?Sized + 'static> SignalUpdate for Signal<T> {
|
||||
type Value<'a> = &'a mut T;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -30,6 +30,7 @@ where
|
||||
S: SignalWith,
|
||||
for<'a> S::Value<'a>: SignalGetCopy<T>,
|
||||
{
|
||||
#[track_caller]
|
||||
fn get(&self) -> T {
|
||||
self.with(|value| value.copy_value())
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ where
|
||||
S: SignalWith,
|
||||
for<'a> S::Value<'a>: SignalGetClone<T>,
|
||||
{
|
||||
#[track_caller]
|
||||
fn get_cloned(&self) -> T {
|
||||
self.with(|value| value.clone_value())
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ where
|
||||
S: SignalUpdate,
|
||||
for<'a> S::Value<'a>: SignalSetWith<T>,
|
||||
{
|
||||
#[track_caller]
|
||||
fn set(&self, new_value: T) {
|
||||
self.update(|value| SignalSetWith::set_value(value, new_value));
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ impl<S: SignalBorrow, T> SignalBorrow for WithDefault<S, T> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
BorrowRef {
|
||||
value: self.inner.borrow(),
|
||||
@ -68,6 +69,7 @@ where
|
||||
{
|
||||
type Value<'a> = &'a T;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -84,6 +86,7 @@ where
|
||||
S: SignalReplace<Option<T>>,
|
||||
T: Copy,
|
||||
{
|
||||
#[track_caller]
|
||||
fn replace(&self, new_value: T) -> T {
|
||||
self.inner.replace(Some(new_value)).unwrap_or(self.default)
|
||||
}
|
||||
@ -93,6 +96,7 @@ impl<S, T> SignalReplace<Option<T>> for WithDefault<S, T>
|
||||
where
|
||||
S: SignalReplace<Option<T>>,
|
||||
{
|
||||
#[track_caller]
|
||||
fn replace(&self, new_value: Option<T>) -> Option<T> {
|
||||
self.inner.replace(new_value)
|
||||
}
|
||||
@ -136,6 +140,7 @@ where
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let mut value = self.inner.borrow_mut();
|
||||
value.get_or_insert(self.default);
|
||||
@ -151,6 +156,7 @@ where
|
||||
{
|
||||
type Value<'a> = &'a mut T;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -63,6 +63,7 @@ impl SignalBorrow for Location {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
BorrowRef(self.0.borrow())
|
||||
}
|
||||
@ -71,6 +72,7 @@ impl SignalBorrow for Location {
|
||||
impl SignalWith for Location {
|
||||
type Value<'a> = &'a Url;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -115,6 +117,7 @@ impl SignalBorrowMut for Location {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let value = self.0.borrow_mut();
|
||||
BorrowRefMut(value)
|
||||
@ -124,6 +127,7 @@ impl SignalBorrowMut for Location {
|
||||
impl SignalUpdate for Location {
|
||||
type Value<'a> = &'a mut Url;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -97,6 +97,7 @@ impl<T: 'static> SignalBorrow for QueryArraySignal<T> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
BorrowRef(self.inner.borrow())
|
||||
}
|
||||
@ -105,6 +106,7 @@ impl<T: 'static> SignalBorrow for QueryArraySignal<T> {
|
||||
impl<T: 'static> SignalWith for QueryArraySignal<T> {
|
||||
type Value<'a> = &'a [T];
|
||||
|
||||
#[track_caller]
|
||||
fn with<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -191,6 +193,7 @@ where
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let value = self.inner.borrow_mut();
|
||||
BorrowRefMut { value, signal: self }
|
||||
@ -203,6 +206,7 @@ where
|
||||
{
|
||||
type Value<'a> = &'a mut Vec<T>;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
@ -96,6 +96,7 @@ impl<T: 'static> SignalBorrow for QuerySignal<T> {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow(&self) -> Self::Ref<'_> {
|
||||
let borrow = self.inner.borrow();
|
||||
borrow.is_some().then(|| BorrowRef(borrow))
|
||||
@ -105,6 +106,7 @@ impl<T: 'static> SignalBorrow for QuerySignal<T> {
|
||||
impl<T: 'static> SignalWith for QuerySignal<T> {
|
||||
type Value<'a> = Option<&'a T>;
|
||||
|
||||
#[track_caller]
|
||||
fn with<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
@ -118,6 +120,7 @@ impl<T> SignalReplace<Option<T>> for QuerySignal<T>
|
||||
where
|
||||
T: ToString + 'static,
|
||||
{
|
||||
#[track_caller]
|
||||
fn replace(&self, new_value: Option<T>) -> Option<T> {
|
||||
mem::replace(&mut self.borrow_mut(), new_value)
|
||||
}
|
||||
@ -188,6 +191,7 @@ where
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[track_caller]
|
||||
fn borrow_mut(&self) -> Self::RefMut<'_> {
|
||||
let value = self.inner.borrow_mut();
|
||||
BorrowRefMut { value, signal: self }
|
||||
@ -200,6 +204,7 @@ where
|
||||
{
|
||||
type Value<'a> = &'a mut Option<T>;
|
||||
|
||||
#[track_caller]
|
||||
fn update<F, O>(&self, f: F) -> O
|
||||
where
|
||||
F: for<'a> FnOnce(Self::Value<'a>) -> O,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user