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

the trait From<Cow<'_, str>> is not implemented for AttrValue #2198

Closed
Madoshakalaka opened this issue Nov 25, 2021 · 3 comments · Fixed by #2200
Closed

the trait From<Cow<'_, str>> is not implemented for AttrValue #2198

Madoshakalaka opened this issue Nov 25, 2021 · 3 comments · Fixed by #2200
Labels
A-yew Area: The main yew crate feature-accepted A feature request that has been accepted and needs implementing feature-request A feature request

Comments

@Madoshakalaka
Copy link
Contributor

Problem

After merging in #1994 in a project code complains

the trait `From<Cow<'_, str>>` is not implemented for `AttrValue`

Currently these are implemented:

impl From<&'static str> for AttrValue {
fn from(s: &'static str) -> Self {
AttrValue::Static(s)
}
}
impl From<String> for AttrValue {
fn from(s: String) -> Self {
AttrValue::Owned(s)
}
}
impl From<Rc<str>> for AttrValue {
fn from(s: Rc<str>) -> Self {
AttrValue::Rc(s)
}
}

Doesn't make sense to omit Cow<'_, str>, as #1994 says

This PR introduces a new type, AttrValue, for attribute values. This is a replacement for Cow<'static, str>

Environment:

  • Yew version: [master]
@Madoshakalaka
Copy link
Contributor Author

Madoshakalaka commented Nov 25, 2021

Need this:

 impl From<Cow<'static, str>> for AttrValue { 
     fn from(s: Cow<'static, str>) -> Self { 
        match s{
            Cow::Borrowed(s) => {
                s.into()
            }
            Cow::Owned(s) => {
                s.into()
            }
        }
     } 
 } 

@ranile ranile added A-yew Area: The main yew crate feature-accepted A feature request that has been accepted and needs implementing feature-request A feature request and removed bug labels Nov 25, 2021
@ranile
Copy link
Member

ranile commented Nov 25, 2021

This seems like good to have. Would you like to PR it?

@Madoshakalaka
Copy link
Contributor Author

This seems like good to have. Would you like to PR it?

will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate feature-accepted A feature request that has been accepted and needs implementing feature-request A feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants