Skip to content

Commit

Permalink
Implement IntoPropValue for Rc<str> (#2285)
Browse files Browse the repository at this point in the history
* add IntoPropValue implementations for Rc<str>

* add test

* update test logs which record the new impls
  • Loading branch information
zstewar1 authored Dec 21, 2021
1 parent 75864e8 commit a166815
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/yew-macro/tests/html_macro/component-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ error[E0277]: the trait bound `{integer}: IntoPropValue<String>` is not satisfie
<&'static str as IntoPropValue<Classes>>
<&'static str as IntoPropValue<Option<AttrValue>>>
<&'static str as IntoPropValue<Option<String>>>
and 12 others
and 15 others

error[E0277]: the trait bound `{integer}: IntoPropValue<String>` is not satisfied
--> tests/html_macro/component-fail.rs:79:34
Expand All @@ -359,7 +359,7 @@ error[E0277]: the trait bound `{integer}: IntoPropValue<String>` is not satisfie
<&'static str as IntoPropValue<Classes>>
<&'static str as IntoPropValue<Option<AttrValue>>>
<&'static str as IntoPropValue<Option<String>>>
and 12 others
and 15 others

error[E0308]: mismatched types
--> tests/html_macro/component-fail.rs:80:31
Expand Down
3 changes: 3 additions & 0 deletions packages/yew-macro/tests/html_macro/element-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ error[E0277]: the trait bound `Option<NotToString>: IntoPropValue<Option<AttrVal
<Option<&'static str> as IntoPropValue<Option<AttrValue>>>
<Option<&'static str> as IntoPropValue<Option<String>>>
<Option<String> as IntoPropValue<Option<AttrValue>>>
<Option<std::rc::Rc<str>> as IntoPropValue<Option<AttrValue>>>
= note: required by `into_prop_value`

error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<AttrValue>>` is not satisfied
Expand All @@ -300,6 +301,7 @@ error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<AttrValue
<Option<&'static str> as IntoPropValue<Option<AttrValue>>>
<Option<&'static str> as IntoPropValue<Option<String>>>
<Option<String> as IntoPropValue<Option<AttrValue>>>
<Option<std::rc::Rc<str>> as IntoPropValue<Option<AttrValue>>>
= note: required by `into_prop_value`

error[E0277]: expected a `Fn<(MouseEvent,)>` closure, found `{integer}`
Expand Down Expand Up @@ -384,6 +386,7 @@ error[E0277]: the trait bound `Option<yew::NodeRef>: IntoPropValue<yew::NodeRef>
<Option<&'static str> as IntoPropValue<Option<AttrValue>>>
<Option<&'static str> as IntoPropValue<Option<String>>>
<Option<String> as IntoPropValue<Option<AttrValue>>>
<Option<std::rc::Rc<str>> as IntoPropValue<Option<AttrValue>>>
= note: required by `into_prop_value`

error[E0277]: expected a `Fn<(MouseEvent,)>` closure, found `yew::Callback<String>`
Expand Down
2 changes: 2 additions & 0 deletions packages/yew/src/html/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl_into_prop!(|value: &'static str| -> String { value.to_owned() });

impl_into_prop!(|value: &'static str| -> AttrValue { AttrValue::Static(value) });
impl_into_prop!(|value: String| -> AttrValue { AttrValue::Owned(value) });
impl_into_prop!(|value: Rc<str>| -> AttrValue { AttrValue::Rc(value) });

#[cfg(test)]
mod test {
Expand All @@ -97,5 +98,6 @@ mod test {
let _: Option<String> = "foo".into_prop_value();
let _: AttrValue = "foo".into_prop_value();
let _: Option<AttrValue> = "foo".into_prop_value();
let _: Option<AttrValue> = Rc::<str>::from("foo").into_prop_value();
}
}

0 comments on commit a166815

Please sign in to comment.