-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
refactor(cli): simplify features: Option<Vec<String>> to Vec<String>
#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
Conversation
crates/tauri-cli/src/mobile/mod.rs
Outdated
| 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.
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.
Made a commit highlighting where serialization is used. This seems purely internal, so going with the simpler serialization.
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.
Unresolved this so we get to see this more obviously if anyone ever get back to this PR
Package Changes Through e68c805There are 6 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-runtime-wry with patch, tauri 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
crates/tauri-cli/src/mobile/mod.rs
Outdated
| 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
|
RFR |
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: Option<Vec<String>> to Vec<String>
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.