From 155b72b0179d9a7b275a600b5134f4242b017f05 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Thu, 18 Jan 2024 08:17:55 -0500 Subject: [PATCH 1/4] Implement Into TextProp for signals --- leptos_reactive/src/signal_wrappers_read.rs | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/leptos_reactive/src/signal_wrappers_read.rs b/leptos_reactive/src/signal_wrappers_read.rs index d703a6ee9a..fd95fdbd3e 100644 --- a/leptos_reactive/src/signal_wrappers_read.rs +++ b/leptos_reactive/src/signal_wrappers_read.rs @@ -1365,6 +1365,33 @@ where } } +impl From> for TextProp +where + T: Into + Clone, +{ + fn from(value: Signal) -> Self { + value.get().into() + } +} + +impl From> for TextProp +where + T: Into + Clone, +{ + fn from(value: ReadSignal) -> Self { + value.get().into() + } +} + +impl From> for TextProp +where + T: Into + Clone, +{ + fn from(value: RwSignal) -> Self { + value.get().into() + } +} + impl Default for TextProp { fn default() -> Self { Self(Rc::new(|| Oco::Borrowed(""))) From 86cb6d032af3fc54d6273f468ff5e6bcaee48e6a Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 22 Jan 2024 12:17:16 -0500 Subject: [PATCH 2/4] cfg gate impls --- leptos_reactive/src/signal_wrappers_read.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/leptos_reactive/src/signal_wrappers_read.rs b/leptos_reactive/src/signal_wrappers_read.rs index fd95fdbd3e..37c96b15ac 100644 --- a/leptos_reactive/src/signal_wrappers_read.rs +++ b/leptos_reactive/src/signal_wrappers_read.rs @@ -1365,6 +1365,7 @@ where } } +#[cfg(not(feature = "nightly"))] impl From> for TextProp where T: Into + Clone, @@ -1374,6 +1375,7 @@ where } } +#[cfg(not(feature = "nightly"))] impl From> for TextProp where T: Into + Clone, @@ -1383,6 +1385,7 @@ where } } +#[cfg(not(feature = "nightly"))] impl From> for TextProp where T: Into + Clone, From b8111e0b699b5be167322793cdb42096c9204358 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 4 Feb 2024 22:34:26 -0500 Subject: [PATCH 3/4] Fix format issue --- leptos_dom/src/html.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leptos_dom/src/html.rs b/leptos_dom/src/html.rs index 1473aeda02..1a65320b81 100644 --- a/leptos_dom/src/html.rs +++ b/leptos_dom/src/html.rs @@ -281,7 +281,7 @@ cfg_if! { /// When `El` has a corresponding [`web_sys::HtmlElement`] -> `El` will implement [`std::ops::Deref`] for it. /// For instance [`leptos::HtmlElement
`] implements [`std::ops::Deref`] for [`web_sys::HtmlDivElement`] /// Because of [Deref Coercion](https://doc.rust-lang.org/std/ops/trait.Deref.html#deref-coercion) you can call applicable [`web_sys::HtmlElement`] methods on `HtmlElement` as if it were that type. - /// If both `HtmlElement` and one of its derefs have a method with the same name, the dot syntax will call the method on the inherent impl (i.e. `HtmlElement` or it's [`std::ops::Deref`] Target). + /// If both `HtmlElement` and one of its derefs have a method with the same name, the dot syntax will call the method on the inherent impl (i.e. `HtmlElement` or it's [`std::ops::Deref`] Target). /// You may need to manually deref to access other methods, for example, `(*el).style()` to get the `CssStyleDeclaration` instead of calling [`leptos::HtmlElement::style`]. #[must_use = "You are creating an HtmlElement<_> but not using it. An unused view can \ From 7ea42d9875e15c69ca467a5953d8fa5762bf93c8 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 4 Feb 2024 22:34:26 -0500 Subject: [PATCH 4/4] Fix format issue --- leptos_dom/src/html.rs | 2 +- router/src/lib.rs | 2 +- server_fn_macro/src/lib.rs | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/leptos_dom/src/html.rs b/leptos_dom/src/html.rs index 1473aeda02..1a65320b81 100644 --- a/leptos_dom/src/html.rs +++ b/leptos_dom/src/html.rs @@ -281,7 +281,7 @@ cfg_if! { /// When `El` has a corresponding [`web_sys::HtmlElement`] -> `El` will implement [`std::ops::Deref`] for it. /// For instance [`leptos::HtmlElement
`] implements [`std::ops::Deref`] for [`web_sys::HtmlDivElement`] /// Because of [Deref Coercion](https://doc.rust-lang.org/std/ops/trait.Deref.html#deref-coercion) you can call applicable [`web_sys::HtmlElement`] methods on `HtmlElement` as if it were that type. - /// If both `HtmlElement` and one of its derefs have a method with the same name, the dot syntax will call the method on the inherent impl (i.e. `HtmlElement` or it's [`std::ops::Deref`] Target). + /// If both `HtmlElement` and one of its derefs have a method with the same name, the dot syntax will call the method on the inherent impl (i.e. `HtmlElement` or it's [`std::ops::Deref`] Target). /// You may need to manually deref to access other methods, for example, `(*el).style()` to get the `CssStyleDeclaration` instead of calling [`leptos::HtmlElement::style`]. #[must_use = "You are creating an HtmlElement<_> but not using it. An unused view can \ diff --git a/router/src/lib.rs b/router/src/lib.rs index f05261688f..b77f0e59fd 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -28,7 +28,7 @@ //! ## Example //! //! ```rust -//! +//! //! use leptos::*; //! use leptos_router::*; //! diff --git a/server_fn_macro/src/lib.rs b/server_fn_macro/src/lib.rs index 885a88a92b..e17d489c8f 100644 --- a/server_fn_macro/src/lib.rs +++ b/server_fn_macro/src/lib.rs @@ -59,14 +59,15 @@ pub fn server_macro_impl( .inputs .iter_mut() .map(|f| { - let typed_arg = - match f { - FnArg::Receiver(_) => return Err(syn::Error::new( + let typed_arg = match f { + FnArg::Receiver(_) => { + return Err(syn::Error::new( f.span(), "cannot use receiver types in server function macro", - )), - FnArg::Typed(t) => t, - }; + )) + } + FnArg::Typed(t) => t, + }; // strip `mut`, which is allowed in fn args but not in struct fields if let Pat::Ident(ident) = &mut *typed_arg.pat {