Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Into TextProp for signals #2199

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion leptos_dom/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Div>`] 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<El>` as if it were that type.
/// If both `HtmlElement<El>` 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<El>` or it's [`std::ops::Deref`] Target).
/// If both `HtmlElement<El>` 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<El>` 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 \
Expand Down
30 changes: 30 additions & 0 deletions leptos_reactive/src/signal_wrappers_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,36 @@ where
}
}

#[cfg(not(feature = "nightly"))]
impl<T> From<Signal<T>> for TextProp
where
T: Into<Self> + Clone,
{
fn from(value: Signal<T>) -> Self {
value.get().into()
}
}

#[cfg(not(feature = "nightly"))]
impl<T> From<ReadSignal<T>> for TextProp
where
T: Into<Self> + Clone,
{
fn from(value: ReadSignal<T>) -> Self {
value.get().into()
}
}

#[cfg(not(feature = "nightly"))]
impl<T> From<RwSignal<T>> for TextProp
where
T: Into<Self> + Clone,
{
fn from(value: RwSignal<T>) -> Self {
value.get().into()
}
}

impl Default for TextProp {
fn default() -> Self {
Self(Rc::new(|| Oco::Borrowed("")))
Expand Down
2 changes: 1 addition & 1 deletion router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! ## Example
//!
//! ```rust
//!
//!
//! use leptos::*;
//! use leptos_router::*;
//!
Expand Down
13 changes: 7 additions & 6 deletions server_fn_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading