Open
Description
Problem
You can write prop_name={&value}
when passing a prop of type Classes
to a component (because Classes
implements ImplicitClone
), but you can't when passing it to an element, requiring you to write prop_name={value.clone()}
instead, which seems inconsistent.
Steps To Reproduce
#[derive(Properties, PartialEq)]
struct Props {
class: Classes,
}
#[function_component]
fn Foo1(props: &Props) -> Html {
html! {
<a class={&props.class} />
}
}
#[function_component]
fn Foo2(props: &Props) -> Html {
html! {
<Foo1 class={&props.class} />
}
}
Expected behavior
Successful compilation
Screenshots
error[E0277]: the trait bound `yew::Classes: std::convert::From<&yew::Classes>` is not satisfied
--> .../foo.rs:69:19
|
68 | / html! {
69 | | <a class={&props.class} />
| | ^^^^^^^^^^^^ the trait `std::convert::From<&yew::Classes>` is not implemented for `yew::Classes`
70 | | }
| |_____- required by a bound introduced by this call
|
= note: required for `&yew::Classes` to implement `std::convert::Into<yew::Classes>`
help: consider dereferencing here
|
69 | <a class={*&props.class} />
| +
Environment:
- Yew version: v0.21
- Rust version: nightly
- Target, if relevant:
wasm32-unknown-unknown
Questionnaire
- I'm interested in fixing this myself but don't know where to start
- I would like to fix and I have a solution
- I don't have time to fix this right now, but maybe later