Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sftse
Copy link
Contributor

@sftse sftse commented Dec 4, 2025

Noticed a code pattern where None is used in place of an empty vector. The resulting code has to transform between different representations and liberally uses get_or_insert on the None. This is a bit roundabout, so use empty Vec as a replacement for None.

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 None and Some(Vec::new()) would have diverged.

@sftse sftse requested a review from a team as a code owner December 4, 2025 13:53
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Dec 4, 2025
Comment on lines 181 to 190
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>,
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Package Changes Through e68c805

There 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 Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.1 2.8.2
tauri-bundler 2.7.5 2.7.6
tauri-runtime 2.9.2 2.9.3
tauri-runtime-wry 2.9.3 2.9.4
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.9.6
@tauri-apps/cli 2.9.6 2.9.7
tauri-cli 2.9.6 2.9.7

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@sftse
Copy link
Contributor Author

sftse commented Dec 5, 2025

@FabianLars
Fixed CI

@sftse
Copy link
Contributor Author

sftse commented Dec 5, 2025

I'm a bit confused by how the change sets work, the bot suggested

---
"@tauri-apps/api": patch
"tauri-utils": patch
"tauri-macos-sign": patch
"tauri-bundler": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
"tauri-codegen": patch
"tauri-macros": patch
"tauri-plugin": patch
"tauri-build": patch
"tauri": patch
"@tauri-apps/cli": patch
"tauri-cli": patch
"tauri-driver": patch
---

even though only tauri-cli has any changes. Is this correct?

@FabianLars
Copy link
Member

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
Legend-Master previously approved these changes Dec 6, 2025
Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Comment on lines 181 to 190
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>,
Copy link
Contributor

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

@sftse
Copy link
Contributor Author

sftse commented Dec 28, 2025

RFR

Legend-Master
Legend-Master previously approved these changes Dec 28, 2025
Legend-Master
Legend-Master previously approved these changes Dec 29, 2025
Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Legend-Master Legend-Master changed the title None empty refactor(cli): simplify features: Option<Vec<String>> to Vec<String> Dec 29, 2025
@Legend-Master Legend-Master merged commit a2abe2e into tauri-apps:dev Dec 29, 2025
18 of 19 checks passed
@github-project-automation github-project-automation bot moved this from 📬Proposal to 🔎 In audit in Roadmap Dec 29, 2025
@sftse sftse deleted the none-empty branch December 29, 2025 16:36
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 In audit

Development

Successfully merging this pull request may close these issues.

3 participants