Skip to content

Convinience Impl for IntoAttributeValue #5444

@tdymel

Description

@tdymel

Feature Request

When I write a component with rsx and I want to add a label, content or put a value, it usually has to be converted IntoAttributeValue first. However, if I provide a reference, for example a &&str or &f32, I would need to Copy/Clone the value first in order to use it.

let test: &'static &'static str = i18n.some_component().some_value();

rsx! {
   span {
      {*test}
   }
}

So I suggest this convenience impl, that does it under the hood.

Implement Suggestion

impl<T> IntoAttributeValue for &T
where
    T: IntoAttributeValue + Clone,
{
    fn into_value(self) -> AttributeValue {
        self.clone().into_value()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions