From e9f29e12292850d990fccb0fc85860e2fdb4614c Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Sun, 22 Dec 2024 15:17:27 +0000 Subject: [PATCH] Fixed `WithDefault` not working for signals that yield `&Option`. --- dynatos-reactive/src/with_default.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dynatos-reactive/src/with_default.rs b/dynatos-reactive/src/with_default.rs index de34f3c..5274844 100644 --- a/dynatos-reactive/src/with_default.rs +++ b/dynatos-reactive/src/with_default.rs @@ -65,7 +65,9 @@ impl SignalBorrow for WithDefault { impl SignalWith for WithDefault where - S: for<'a> SignalWith = Option<&'a T>>, + S: SignalWith, + // Note: This allows both `Option<&'_ T>` and `&'_ Option` + for<'a> S::Value<'a>: Into>, T: 'static, { type Value<'a> = &'a T; @@ -75,13 +77,15 @@ where where F: for<'a> FnOnce(Self::Value<'a>) -> O, { - self.inner.with(|value| match value { + self.inner.with(|value| match value.into() { Some(value) => f(value), None => f(&self.default), }) } } +// TODO: Impl `SignalGet>` once we can? + impl SignalReplace for WithDefault where S: SignalReplace>,