Skip to content

Commit

Permalink
fix(Metadata): set a default value on workspace_default_members deser…
Browse files Browse the repository at this point in the history
…ialization
  • Loading branch information
zjp-CN committed Oct 2, 2024
1 parent 48d9985 commit dc53ab2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pub struct Metadata {
/// The list of default workspace members
///
/// This not available if running with a version of Cargo older than 1.71.
#[serde(default = "empty_workspace_default_members")]
#[serde(skip_serializing_if = "workspace_default_members_is_missing")]
pub workspace_default_members: WorkspaceDefaultMembers,
/// Dependencies graph
Expand Down Expand Up @@ -259,6 +260,14 @@ pub fn workspace_default_members_is_missing(
workspace_default_members.0.is_none()
}

/// A default value when Metadata is deserialized with WorkspaceDefaultMembers skipped.
///
/// We use this function for now because WorkspaceDefaultMembers doesn't implement Default.
#[doc(hidden)]
pub fn empty_workspace_default_members() -> WorkspaceDefaultMembers {
WorkspaceDefaultMembers(None)
}

#[derive(Clone, Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "builder", derive(Builder))]
#[non_exhaustive]
Expand Down

0 comments on commit dc53ab2

Please sign in to comment.