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.
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
[x] 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
This could be fixed by adding an impl From<&Classes> for Classes, but I'm curious why html! is using From instead of IntoPropValue (as in component props) in the first place.
Problem You can write
prop_name={&value}
when passing a prop of typeClasses
to a component (becauseClasses
implementsImplicitClone
), but you can't when passing it to an element, requiring you to writeprop_name={value.clone()}
instead, which seems inconsistent.Steps To Reproduce
Expected behavior Successful compilation
Screenshots
Environment:
wasm32-unknown-unknown
Questionnaire