From ed028fc21825ed50fe8bcbc2d22232b7300c5b45 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 17 Nov 2024 16:31:06 -0500 Subject: [PATCH 1/3] fix: type inference regression due to `From for Signal` impl (closes #3200) --- leptos/tests/generic_component.rs | 25 ++++++++++++ reactive_graph/src/wrappers.rs | 63 ++----------------------------- 2 files changed, 28 insertions(+), 60 deletions(-) create mode 100644 leptos/tests/generic_component.rs diff --git a/leptos/tests/generic_component.rs b/leptos/tests/generic_component.rs new file mode 100644 index 0000000000..966e45ce79 --- /dev/null +++ b/leptos/tests/generic_component.rs @@ -0,0 +1,25 @@ +#[test] +fn generic_component_signal_inference() { + use leptos::prelude::*; + + #[component] + pub fn SimpleCounter(#[prop(into)] step: Signal) -> impl IntoView + where + T: Send + Sync + 'static, + { + _ = step; + view! { +
+
+ } + } + + let a = RwSignal::new(1); + let (b, _) = signal(1); + + view! { + + + + }; +} diff --git a/reactive_graph/src/wrappers.rs b/reactive_graph/src/wrappers.rs index 37ac879401..543b27c887 100644 --- a/reactive_graph/src/wrappers.rs +++ b/reactive_graph/src/wrappers.rs @@ -606,33 +606,6 @@ pub mod read { } } - impl From for ArcSignal { - #[track_caller] - fn from(value: T) -> Self { - ArcSignal::stored(value) - } - } - - impl From for Signal - where - T: Send + Sync + 'static, - { - #[track_caller] - fn from(value: T) -> Self { - Self::stored(value) - } - } - - impl From for Signal - where - T: 'static, - { - #[track_caller] - fn from(value: T) -> Self { - Self::stored_local(value) - } - } - impl From> for Signal where T: Send + Sync + 'static, @@ -856,36 +829,6 @@ pub mod read { } } - impl From for Signal> - where - T: Send + Sync + 'static, - { - #[track_caller] - fn from(value: T) -> Self { - Signal::stored(Some(value)) - } - } - - impl From for Signal, LocalStorage> - where - T: 'static, - { - #[track_caller] - fn from(value: T) -> Self { - Signal::stored_local(Some(value)) - } - } - - impl From> for Signal> - where - T: Clone + Send + Sync + 'static, - { - #[track_caller] - fn from(value: Signal) -> Self { - Signal::derive(move || Some(value.get())) - } - } - impl From> for Signal, LocalStorage> where T: Clone + 'static, @@ -1080,8 +1023,8 @@ pub mod read { #[deprecated( since = "0.7.0-rc1", note = "`MaybeSignal` is deprecated in favour of `Signal` which \ - is `Copy`, now has a more efficient From implementation \ - and other benefits in 0.7." + is `Copy`, and has other benefits in 0.7. `Signal` can be \ + created from `T` with `Signal::stored()`." )] pub enum MaybeSignal where @@ -1574,7 +1517,7 @@ pub mod read { impl From<&str> for MaybeProp { fn from(value: &str) -> Self { - Self(Some(Signal::from(Some(value.to_string())))) + Self(Some(Signal::stored(Some(value.to_string())))) } } From 78c21678aa5002be96dfce8933e8ac1a9bd75083 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 17 Nov 2024 18:51:51 -0500 Subject: [PATCH 2/3] update examples --- examples/errors_axum/src/landing.rs | 1 + examples/timer/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/errors_axum/src/landing.rs b/examples/errors_axum/src/landing.rs index 4fe0d0f768..0ed62ed03c 100644 --- a/examples/errors_axum/src/landing.rs +++ b/examples/errors_axum/src/landing.rs @@ -48,6 +48,7 @@ pub fn App() -> impl IntoView { } diff --git a/examples/timer/src/lib.rs b/examples/timer/src/lib.rs index c04241940c..48ac44b9e8 100644 --- a/examples/timer/src/lib.rs +++ b/examples/timer/src/lib.rs @@ -38,7 +38,7 @@ pub fn TimerDemo() -> impl IntoView { pub fn use_interval(interval_millis: T, f: F) where F: Fn() + Clone + 'static, - T: Into> + 'static, + T: Into> + 'static, { let interval_millis = interval_millis.into(); Effect::new(move |prev_handle: Option| { From ed732192f03eec7cdbabac65e8b1c659e9e8c9a5 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 17 Nov 2024 19:00:03 -0500 Subject: [PATCH 3/3] remove deprecation on MaybeSignal --- reactive_graph/src/wrappers.rs | 38 ---------------------------------- 1 file changed, 38 deletions(-) diff --git a/reactive_graph/src/wrappers.rs b/reactive_graph/src/wrappers.rs index 543b27c887..c8fa4c2867 100644 --- a/reactive_graph/src/wrappers.rs +++ b/reactive_graph/src/wrappers.rs @@ -911,7 +911,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for Signal where T: Send + Sync + 'static, @@ -925,7 +924,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for Signal where T: Send + Sync + 'static, @@ -939,7 +937,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for Signal> where T: Clone + Send + Sync + 'static, @@ -955,7 +952,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for Signal, LocalStorage> where T: Clone + Send + Sync + 'static, @@ -1020,12 +1016,6 @@ pub mod read { /// assert_eq!(above_3(&memoized_double_count.into()), true); /// ``` #[derive(Debug, PartialEq, Eq)] - #[deprecated( - since = "0.7.0-rc1", - note = "`MaybeSignal` is deprecated in favour of `Signal` which \ - is `Copy`, and has other benefits in 0.7. `Signal` can be \ - created from `T` with `Signal::stored()`." - )] pub enum MaybeSignal where T: 'static, @@ -1037,7 +1027,6 @@ pub mod read { Dynamic(Signal), } - #[allow(deprecated)] impl Clone for MaybeSignal where S: Storage, @@ -1050,10 +1039,8 @@ pub mod read { } } - #[allow(deprecated)] impl Copy for MaybeSignal where S: Storage {} - #[allow(deprecated)] impl Default for MaybeSignal where S: Storage, @@ -1063,7 +1050,6 @@ pub mod read { } } - #[allow(deprecated)] impl DefinedAt for MaybeSignal where S: Storage, @@ -1075,7 +1061,6 @@ pub mod read { } } - #[allow(deprecated)] impl Track for MaybeSignal where S: Storage + Storage>, @@ -1088,7 +1073,6 @@ pub mod read { } } - #[allow(deprecated)] impl ReadUntracked for MaybeSignal where T: Clone, @@ -1113,7 +1097,6 @@ pub mod read { } } - #[allow(deprecated)] impl MaybeSignal where T: Send + Sync, @@ -1127,7 +1110,6 @@ pub mod read { } } - #[allow(deprecated)] impl MaybeSignal { /// Wraps a derived signal, i.e., any computation that accesses one or more /// reactive signals. @@ -1136,7 +1118,6 @@ pub mod read { } } - #[allow(deprecated)] impl From for MaybeSignal where SyncStorage: Storage, @@ -1146,7 +1127,6 @@ pub mod read { } } - #[allow(deprecated)] impl FromLocal for MaybeSignal where LocalStorage: Storage, @@ -1156,7 +1136,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync, @@ -1166,14 +1145,12 @@ pub mod read { } } - #[allow(deprecated)] impl From> for MaybeSignal { fn from(value: ReadSignal) -> Self { Self::Dynamic(value.into()) } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync, @@ -1183,14 +1160,12 @@ pub mod read { } } - #[allow(deprecated)] impl From> for MaybeSignal { fn from(value: RwSignal) -> Self { Self::Dynamic(value.into()) } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync, @@ -1200,14 +1175,12 @@ pub mod read { } } - #[allow(deprecated)] impl From> for MaybeSignal { fn from(value: Memo) -> Self { Self::Dynamic(value.into()) } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync, @@ -1217,14 +1190,12 @@ pub mod read { } } - #[allow(deprecated)] impl FromLocal> for MaybeSignal { fn from_local(value: ArcReadSignal) -> Self { ReadSignal::from_local(value).into() } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync + 'static, @@ -1234,7 +1205,6 @@ pub mod read { } } - #[allow(deprecated)] impl FromLocal> for MaybeSignal where T: 'static, @@ -1244,7 +1214,6 @@ pub mod read { } } - #[allow(deprecated)] impl From> for MaybeSignal where T: Send + Sync, @@ -1254,14 +1223,12 @@ pub mod read { } } - #[allow(deprecated)] impl FromLocal> for MaybeSignal { fn from_local(value: ArcMemo) -> Self { Memo::from_local(value).into() } } - #[allow(deprecated)] impl From> for MaybeSignal where S: Storage, @@ -1271,7 +1238,6 @@ pub mod read { } } - #[allow(deprecated)] impl From<&str> for MaybeSignal where S: Storage + Storage>>, @@ -1420,7 +1386,6 @@ pub mod read { } } - #[allow(deprecated)] impl From>> for MaybeProp where T: Send + Sync, @@ -1431,7 +1396,6 @@ pub mod read { } } - #[allow(deprecated)] impl From>>> for MaybeProp where T: Send + Sync, @@ -1543,7 +1507,6 @@ pub mod read { } } - #[allow(deprecated)] impl From, LocalStorage>> for MaybeProp where @@ -1554,7 +1517,6 @@ pub mod read { } } - #[allow(deprecated)] impl From, LocalStorage>>> for MaybeProp where