diff --git a/examples/directives/src/lib.rs b/examples/directives/src/lib.rs index 737e37f4f..f9c34d03a 100644 --- a/examples/directives/src/lib.rs +++ b/examples/directives/src/lib.rs @@ -53,7 +53,6 @@ impl From<()> for Amount { } } -// .into() will automatically be called on the parameter pub fn add_dot(el: Element, amount: Amount) { use leptos::wasm_bindgen::JsCast; let el = el.unchecked_into::(); @@ -82,12 +81,17 @@ pub fn App() -> impl IntoView { let data = "Hello World!"; view! { - "Copy \"" {data} "\" to clipboard" + + "Copy \"" + {data} + "\" to clipboard" + // automatically applies the directive to every root element in `SomeComponent` - + // no value will default to `().into()` - // `5.into()` automatically called - + // can manually call `.into()` to convert to the correct type + // (automatically calling `.into()` prevents using generics in directive functions) + } } diff --git a/leptos_macro/src/view/mod.rs b/leptos_macro/src/view/mod.rs index 62d7ffb40..6663cecf1 100644 --- a/leptos_macro/src/view/mod.rs +++ b/leptos_macro/src/view/mod.rs @@ -520,7 +520,7 @@ pub(crate) fn attribute_absolute( } else if id == "use" { let key = &parts[1]; let param = if let Some(value) = node.value() { - quote!(::std::convert::Into::into(#value)) + quote!(#value) } else { quote_spanned!(node.key.span()=> ().into()) }; @@ -1071,7 +1071,7 @@ pub(crate) fn directive_call_from_attribute_node( let handler = syn::Ident::new(directive_name, attr.key.span()); let param = if let Some(value) = attr.value() { - quote!(::std::convert::Into::into(#value)) + quote!(#value) } else { quote_spanned!(attr.key.span()=> ().into()) };