-
-
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
Merged
futursolo
merged 6 commits into
yewstack:master
from
its-the-shrimp:remove-option-special-case
Sep 23, 2023
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8cc02a8
removed PropAttr::Option
its-the-shrimp 247a207
fixed formatting
its-the-shrimp 7997d85
removed an irrelevant test
its-the-shrimp 471f259
added a test for converting value into Some(value) in the html! macro
its-the-shrimp 1771ce8
added more tests for derive(Properties)
its-the-shrimp 4de7160
added more tests (again)
its-the-shrimp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,18 +220,6 @@ mod t11 { | |
} | ||
} | ||
|
||
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 } }; | ||
} | ||
} | ||
|
||
#[deny(non_snake_case, dead_code)] | ||
mod t13 { | ||
#[derive(::std::cmp::PartialEq, ::yew::Properties)] | ||
|
@@ -249,7 +237,25 @@ mod raw_field_names { | |
r#true: u32, | ||
r#pointless_raw_name: u32, | ||
} | ||
} | ||
|
||
mod value_into_some_value_in_props { | ||
#[derive(::std::cmp::PartialEq, ::yew::Properties)] | ||
struct Props { | ||
field1: ::std::option::Option<usize>, | ||
#[prop_or_default] | ||
field2: ::std::option::Option<usize> | ||
} | ||
|
||
#[::yew::function_component] | ||
fn Inner(_props: &Props) -> ::yew::html::Html { | ||
::yew::html!{} | ||
} | ||
|
||
#[::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 commentThe 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. |
||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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