mirror of
https://github.com/Zenithsiz/dynatos.git
synced 2026-02-08 04:55:59 +00:00
Fixed WithDefault not working for signals that yield &Option<T>.
This commit is contained in:
parent
91b7927e3b
commit
e9f29e1229
@ -65,7 +65,9 @@ impl<S: SignalBorrow, T> SignalBorrow for WithDefault<S, T> {
|
||||
|
||||
impl<S, T> SignalWith for WithDefault<S, T>
|
||||
where
|
||||
S: for<'a> SignalWith<Value<'a> = Option<&'a T>>,
|
||||
S: SignalWith,
|
||||
// Note: This allows both `Option<&'_ T>` and `&'_ Option<T>`
|
||||
for<'a> S::Value<'a>: Into<Option<&'a T>>,
|
||||
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<Option<T>>` once we can?
|
||||
|
||||
impl<S, T> SignalReplace<T> for WithDefault<S, T>
|
||||
where
|
||||
S: SignalReplace<Option<T>>,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user