-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Bring back &str assignment to optional properties #1895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure there was a reason for the IntoOptPropValue
trait. Part of it was that it makes it possible to distinguish between "optional" attributes and attributes which just happen to be Option
's.
Most of the useful properties of IntoOptPropValue
didn't work out though because of the lack of specialization... Given that, I believe it totally makes sense to simplify the system back to just IntoPropValue<Option<T>>
.
packages/yew/src/html/conversion.rs
Outdated
html! { | ||
<MockComponent | ||
cow_string="foo" | ||
cow_string_opt="foo" | ||
string="foo" | ||
string_opt="foo" | ||
r#usize=12 | ||
usize_opt=12 | ||
/> | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you perhaps test the IntoPropValue
macro directly instead of through the macro?
i.e. just:
IntoPropValue::<String>("foo");
IntoPropValue::<Option<String>>("foo");
Also, since these are essentially compile tests, we should consider using trybuild for these too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to:
fn test_str() {
let _: String = "foo".into_prop_value();
let _: Option<String> = "foo".into_prop_value();
let _: Cow<'static, str> = "foo".into_prop_value();
let _: Option<Cow<'static, str>> = "foo".into_prop_value();
}
This should go in |
98bd402
to
8cd8341
Compare
For me it is hard to understand where what the current state of this repository is. So apologies if I targeted the wrong branch. I will try to rebase this on master. |
8cd8341
to
68b9047
Compare
I changed the base for the PR to target |
Hm, what's going on with the unit tests? |
If I were to guess, the |
f30be11
to
4347b00
Compare
This drops the "optional" conversion concept in favor of directly converting to `Option<T>`. fixes yewstack#1888
4347b00
to
8dcc4e5
Compare
Yes, I struggled a bit with these. But it looks green now. |
This drops the "optional" conversion concept in favor of directly converting to
Option<T>
.Description
This drops the
IntoOptPropValue
trait, and uses a conversion toOption<T>
instead. This brings back the ability to assign&str
to anOption<String>
orOption<Cow<'static, str>>
property.Fixes #1888
Checklist
cargo make pr-flow