-
-
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
Remove special handing of struct fields of type Option
in derive(Properties)
#3398
Remove special handing of struct fields of type Option
in derive(Properties)
#3398
Conversation
Visit the preview URL for this PR (updated for commit 4de7160): https://yew-rs-api--pr3398-remove-option-specia-b2jmg0pe.web.app (expires Tue, 19 Sep 2023 20:07:51 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew Master
Pull Request
|
Does converting |
added a test for that, it passes |
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.
Thanks for the PR! It looks good, just a couple of comments, only related to tests
mod t12 { | ||
#[derive(::std::clone::Clone, ::yew::Properties, ::std::cmp::PartialEq)] | ||
pub struct Props<T: ::std::clone::Clone + ::std::cmp::PartialEq> { | ||
value: ::std::option::Option<T>, | ||
} | ||
|
||
fn optional_prop_generics_should_work() { | ||
::yew::props! { Props::<::std::primitive::bool> { } }; | ||
::yew::props! { Props::<::std::primitive::bool> { value: true } }; | ||
} | ||
} | ||
|
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.
Why remove this test? We should not be removing tests. I would like to have this change not come at the cost of functionality. Please add the test back
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.
This test (or half of it) would go into fail.rs
then, as it produces the problem this PR addresses.
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.
Also I should note that tests being removed all the time is a normal procedure for many developers. Tests can be removed if they do not reflect current reality (i.e. do not pass, in this case because behavior is opposite to what previously was tested for), are covered by other tests (which have been added (will be added per your suggestions) in this PR by the way), or simply poorly written or considered more of a burden for development than the sought for assistance they are supposed to give.
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.
Also I should note that tests being removed all the time is a normal procedure for many developers. Tests can be removed if they do not reflect current reality (i.e. do not pass, in this case because behavior is opposite to what previously was tested for), are covered by other tests (which have been added (will be added per your suggestions) in this PR by the way), or simply poorly written or considered more of a burden for development than the sought for assistance they are supposed to give.
Absolutely, but in this case, the test can be updated to be passed and covers a very important functionality: generic props. We should have a passing test for that feature
|
||
#[::yew::function_component] | ||
fn Main() -> ::yew::html::Html { | ||
::yew::html! { <Inner field1=3 field2=5/> } |
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.
Can you also add a case where only the required field is passed? Also, please add an identical test but failing where it doesn't pass the required prop.
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.
Thanks! Looks good to me
Description
Fixes #3395
Checklist