refactor(cli): simplify features: Option<Vec<String>> to Vec<String>#14607
refactor(cli): simplify features: Option<Vec<String>> to Vec<String>#14607Legend-Master merged 8 commits intotauri-apps:devfrom
features: Option<Vec<String>> to Vec<String>#14607Conversation
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.
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.
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.
Think I checked this (not at workstation rn) and only used internally, will get back to you.
There was a problem hiding this comment.
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.
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) |
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.
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 |
features: Option<Vec<String>> to Vec<String>
* refactor(tauri-cli): introduce replacement functions * refactor(tauri-cli): apply replacement to remove.rs * refactor(tauri-cli): apply replacement to icon.rs * refactor(tauri-cli): apply replacement to bundle.rs * refactor(tauri-cli): apply replacement to build.rs * refactor(tauri-cli): apply replacement to add.rs * refactor(tauri-cli): apply replacement to dev.rs * refactor(tauri-cli): less controlflow * refactor(tauri-cli): split config loading from locking static * refactor(tauri-cli): remove duplicate checks covered by if let Some(tauri_dir) = tauri_dir tauri_dir.is_some() must be true, otherwise the entire block is not run, so the frontend_dir check is irrelevant * fmt * refactor(tauri-cli): apply replacement to inspect.rs * refactor(tauri-cli): dont use statics for config * refactor(tauri-cli): finish threading directory paths through functions * fix: clippy * fixup CI * refactor(tauri-cli): dont need mutex * refactor(tauri-cli): rescope mutex use to minimal necessary * fix CI, reduce mutex use * fixup PR #14607 * fix: clippy * refactor(tauri-cli): remove ConfigHandle * refactor(tauri-cli): remove more unwraps and panicing functions * refactor(tauri-cli): less mutexes * refactor(tauri-cli): undo mistaken change, address review comment * Split android build to 2 functions * Pass in dirs to migration v1 like the v2 beta * Add change file --------- Co-authored-by: Tony <legendmastertony@gmail.com>
* refactor(tauri-cli): introduce replacement functions * refactor(tauri-cli): apply replacement to remove.rs * refactor(tauri-cli): apply replacement to icon.rs * refactor(tauri-cli): apply replacement to bundle.rs * refactor(tauri-cli): apply replacement to build.rs * refactor(tauri-cli): apply replacement to add.rs * refactor(tauri-cli): apply replacement to dev.rs * refactor(tauri-cli): less controlflow * refactor(tauri-cli): split config loading from locking static * refactor(tauri-cli): remove duplicate checks covered by if let Some(tauri_dir) = tauri_dir tauri_dir.is_some() must be true, otherwise the entire block is not run, so the frontend_dir check is irrelevant * fmt * refactor(tauri-cli): apply replacement to inspect.rs * refactor(tauri-cli): dont use statics for config * refactor(tauri-cli): finish threading directory paths through functions * fix: clippy * fixup CI * refactor(tauri-cli): dont need mutex * refactor(tauri-cli): rescope mutex use to minimal necessary * fix CI, reduce mutex use * fixup PR tauri-apps#14607 * fix: clippy * refactor(tauri-cli): remove ConfigHandle * refactor(tauri-cli): remove more unwraps and panicing functions * refactor(tauri-cli): less mutexes * refactor(tauri-cli): undo mistaken change, address review comment * Split android build to 2 functions * Pass in dirs to migration v1 like the v2 beta * Add change file --------- Co-authored-by: Tony <legendmastertony@gmail.com>
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.