mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
remove Into<_> by default for setting signals, because it interferes with type inference
This commit is contained in:
parent
0c7c7c9b38
commit
025c28b489
3 changed files with 10 additions and 15 deletions
|
@ -127,7 +127,7 @@ impl<T: Send + Sync + 'static> ArcReadSignal<T> {
|
|||
let mut stream = Box::pin(stream);
|
||||
Executor::spawn(async move {
|
||||
while let Some(value) = stream.next().await {
|
||||
write.set(value);
|
||||
write.set(Some(value));
|
||||
}
|
||||
});
|
||||
read
|
||||
|
@ -142,7 +142,7 @@ impl<T: 'static> ArcReadSignal<T> {
|
|||
let mut stream = Box::pin(stream);
|
||||
Executor::spawn_local(async move {
|
||||
while let Some(value) = stream.next().await {
|
||||
write.set(value);
|
||||
write.set(Some(value));
|
||||
}
|
||||
});
|
||||
read
|
||||
|
@ -157,7 +157,7 @@ impl<T: Send + Sync + 'static> ReadSignal<T> {
|
|||
let mut stream = Box::pin(stream);
|
||||
Executor::spawn(async move {
|
||||
while let Some(value) = stream.next().await {
|
||||
write.set(value);
|
||||
write.set(Some(value));
|
||||
}
|
||||
});
|
||||
read
|
||||
|
@ -172,7 +172,7 @@ impl<T: 'static> ReadSignal<T> {
|
|||
let mut stream = Box::pin(stream);
|
||||
Executor::spawn_local(async move {
|
||||
while let Some(value) = stream.next().await {
|
||||
write.set(value);
|
||||
write.set(Some(value));
|
||||
}
|
||||
});
|
||||
read
|
||||
|
|
|
@ -387,9 +387,9 @@ where
|
|||
pub trait Set {
|
||||
type Value;
|
||||
|
||||
fn set(&self, value: impl Into<Self::Value>);
|
||||
fn set(&self, value: Self::Value);
|
||||
|
||||
fn try_set(&self, value: impl Into<Self::Value>) -> Option<Self::Value>;
|
||||
fn try_set(&self, value: Self::Value) -> Option<Self::Value>;
|
||||
}
|
||||
|
||||
impl<T> Set for T
|
||||
|
@ -399,12 +399,12 @@ where
|
|||
type Value = <Self as Update>::Value;
|
||||
|
||||
#[track_caller]
|
||||
fn set(&self, value: impl Into<Self::Value>) {
|
||||
fn set(&self, value: Self::Value) {
|
||||
self.try_update(|n| *n = value.into());
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn try_set(&self, value: impl Into<Self::Value>) -> Option<Self::Value> {
|
||||
fn try_set(&self, value: Self::Value) -> Option<Self::Value> {
|
||||
if self.is_disposed() {
|
||||
Some(value.into())
|
||||
} else {
|
||||
|
|
|
@ -726,8 +726,7 @@ pub mod write {
|
|||
impl<T> Set for SignalSetter<T> {
|
||||
type Value = T;
|
||||
|
||||
fn set(&self, new_value: impl Into<Self::Value>) {
|
||||
let new_value = new_value.into();
|
||||
fn set(&self, new_value: Self::Value) {
|
||||
match self.inner {
|
||||
SignalSetterTypes::Default => {}
|
||||
SignalSetterTypes::Write(w) => w.set(new_value),
|
||||
|
@ -737,11 +736,7 @@ pub mod write {
|
|||
}
|
||||
}
|
||||
|
||||
fn try_set(
|
||||
&self,
|
||||
new_value: impl Into<Self::Value>,
|
||||
) -> Option<Self::Value> {
|
||||
let new_value = new_value.into();
|
||||
fn try_set(&self, new_value: Self::Value) -> Option<Self::Value> {
|
||||
match self.inner {
|
||||
SignalSetterTypes::Default => Some(new_value),
|
||||
SignalSetterTypes::Write(w) => w.try_set(new_value),
|
||||
|
|
Loading…
Reference in a new issue