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
.clone()
.unwrap_or_default();
for bin in bins {
if let (Some(req_features), Some(opt_features)) =
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 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.

Comment on lines +138 to +142
features: if android_options.features.is_empty() {
None
} else {
Some(android_options.features.clone())
},
Copy link
Contributor Author

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())

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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

Comment on lines -164 to +167
features: android_options.features,
features: if android_options.features.is_empty() {
None
} else {
Some(android_options.features)
},
Copy link
Contributor Author

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.

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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Package Changes Through e6623ea

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

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

package current next
tauri-macos-sign 2.3.1 2.3.2
tauri-bundler 2.7.4 2.7.5
@tauri-apps/cli 2.9.5 2.9.6
tauri-cli 2.9.5 2.9.6

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)

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 +138 to +142
features: if android_options.features.is_empty() {
None
} else {
Some(android_options.features.clone())
},
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

3 participants