Skip to content

IntoPropValue errors when migrating to 0.18 #1974

Answered by mc1098
huntc asked this question in Q&A
Discussion options

You must be logged in to vote

Hey 👋

Is it that I must use an explicit .to_string() for each attribute?

Yes, Yew used to call ToString::to_string for you before 0.18.0, which in this case is convenient, however, when passing something like an owned String to a child Component this would cause the String to be cloned when it might only need to be borrowed. So Yew 0.18.0 uses Cows under the hood so that owned Strings can be borrowed and only cloned on write.

If your const/static variables are only being used in the html! macro for setting attributes then you can consider using &'static to avoid the to_string calls.

In your Properties, to avoid needless cloning, you can change the String fields to Cow<'static, str>:

Bef…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@huntc
Comment options

Answer selected by huntc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants