-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
None empty #14607
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
base: dev
Are you sure you want to change the base?
None empty #14607
Conversation
| .clone() | ||
| .unwrap_or_default(); | ||
| for bin in bins { | ||
| if let (Some(req_features), Some(opt_features)) = |
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 code previously had different behavior if options.features was Some(Vec::new()) (continue hit) vs None (continue not hit). This is odd given the variable names which imply the required features should be present.
| features: if android_options.features.is_empty() { | ||
| None | ||
| } else { | ||
| Some(android_options.features.clone()) | ||
| }, |
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.
Did not check how this external type behaves, so this if branch might be overly conservative and replaceable with Some(android_options.features.clone())
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 don't think it's being used at all currently, so wouldn't matter either ways
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'll check, just to make sure this is future-proof, even if it's not used.
Alternatively, if things are not used, should we remove them?
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.
Alternatively, if things are not used, should we remove them?
I'm not the most familiar with it, maybe @lucasfernog knows about them a bit more
| features: android_options.features, | ||
| features: if android_options.features.is_empty() { | ||
| None | ||
| } else { | ||
| Some(android_options.features) | ||
| }, |
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.
Same here, if branch maybe removable.
| fn is_empty(v: &[String]) -> bool { | ||
| v.is_empty() | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct CliOptions { | ||
| pub dev: bool, | ||
| pub features: Option<Vec<String>>, | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "is_empty")] | ||
| pub features: Vec<String>, |
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 Serialize and Deserialize impl is the only publically visible way the change of internal fields might be observable. This uses serde configuration so serialization strings remain identical.
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 think this is also different from before, it used to be something like "features": null in JSON
Since I'm not the most familiar with where is this used, I'll leave it to @FabianLars @lucasfernog
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.
Think I checked this (not at workstation rn) and only used internally, will get back to you.
Package Changes Through e6623eaThere are 4 changes which include tauri-macos-sign with patch, @tauri-apps/cli with patch, tauri-cli with patch, tauri-bundler with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
@FabianLars |
|
I'm a bit confused by how the change sets work, the bot suggested even though only |
|
no the bot just lists all existing packages. just remove all that you didn't touch (eg in your case only tauri-cli needs to be there) |
Legend-Master
left a comment
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
| features: if android_options.features.is_empty() { | ||
| None | ||
| } else { | ||
| Some(android_options.features.clone()) | ||
| }, |
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 don't think it's being used at all currently, so wouldn't matter either ways
| } | ||
| }), | ||
| ios_features: ios_options.features.clone(), | ||
| ios_features: if ios_options.features.is_empty() { |
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.
Same here
| fn is_empty(v: &[String]) -> bool { | ||
| v.is_empty() | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct CliOptions { | ||
| pub dev: bool, | ||
| pub features: Option<Vec<String>>, | ||
| #[serde(default)] | ||
| #[serde(skip_serializing_if = "is_empty")] | ||
| pub features: Vec<String>, |
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 think this is also different from before, it used to be something like "features": null in JSON
Since I'm not the most familiar with where is this used, I'll leave it to @FabianLars @lucasfernog
Noticed a code pattern where
Noneis used in place of an empty vector. The resulting code has to transform between different representations and liberally usesget_or_inserton theNone. This is a bit roundabout, so use emptyVecas a replacement forNone.Empty
Vecs don't allocate, so this changes nothing except make the code shorter.Not entirely sure, but also think this fixes a bug where the code paths of
NoneandSome(Vec::new())would have diverged.