Skip to content
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

refactor: mark types as non_exhaustive #84

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/non-exhuastive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-packager": minor
---

Mark most of the types as `non_exhaustive` to allow adding more field later on without having to break downstream users use the newly added helper methods on these types to modify the corresponding fields in-place.
12 changes: 6 additions & 6 deletions bindings/updater/nodejs/src/from_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ impl From<cargo_packager_updater::WindowsUpdateInstallMode> for WindowsUpdateIns
impl From<cargo_packager_updater::UpdaterWindowsConfig> for UpdaterWindowsOptions {
fn from(value: cargo_packager_updater::UpdaterWindowsConfig) -> Self {
Self {
installer_args: Some(value.installer_args),
install_mode: Some(value.install_mode.into()),
installer_args: value.installer_args,
install_mode: value.install_mode.map(Into::into),
}
}
}
impl From<UpdaterWindowsOptions> for cargo_packager_updater::UpdaterWindowsConfig {
fn from(value: UpdaterWindowsOptions) -> Self {
Self {
installer_args: value.installer_args.unwrap_or_default(),
install_mode: value.install_mode.map(Into::into).unwrap_or_default(),
installer_args: value.installer_args,
install_mode: value.install_mode.map(Into::into),
}
}
}
Expand All @@ -46,7 +46,7 @@ impl From<Options> for cargo_packager_updater::Config {
.filter_map(|e| e.parse().ok())
.collect(),
pubkey: value.pubkey,
windows: value.windows.map(Into::into).unwrap_or_default(),
windows: value.windows.map(Into::into),
}
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ impl From<cargo_packager_updater::Update> for Update {
})
.collect(),
format: value.format.into(),
windows: value.config.windows.into(),
windows: value.config.windows.map(Into::into),
}
}
}
4 changes: 2 additions & 2 deletions bindings/updater/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub struct Update {
/// Update format
pub format: UpdateFormat,
/// The Windows options for the updater.
pub windows: UpdaterWindowsOptions,
pub windows: Option<UpdaterWindowsOptions>,
/// Update description
pub body: Option<String>,
/// Update publish date
Expand All @@ -138,7 +138,7 @@ impl Update {
Ok(cargo_packager_updater::Update {
config: cargo_packager_updater::Config {
pubkey: self.pubkey.clone(),
windows: self.windows.clone().into(),
windows: self.windows.clone().map(Into::into),
..Default::default()
},
body: self.body.clone(),
Expand Down
Loading
Loading