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

skip serializing 'yanked' bool if false #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/api/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub(crate) async fn put(mut req: Request<State>) -> Result<Response, Error> {
.collect(),
cksum: hash,
features: metadata.features,
yanked: Some(false),
yanked: false,
links: metadata.links,
};

Expand Down
4 changes: 2 additions & 2 deletions src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ pub trait Indexer {
F: FnOnce(&mut CrateVersion);
/// Yanks a crate version.
fn yank_record(&self, name: &str, version: Version) -> Result<(), Error> {
self.alter_record(name, version, |krate| krate.yanked = Some(true))
self.alter_record(name, version, |krate| krate.yanked = true)
}
/// Un-yanks a crate version.
fn unyank_record(&self, name: &str, version: Version) -> Result<(), Error> {
self.alter_record(name, version, |krate| krate.yanked = Some(false))
self.alter_record(name, version, |krate| krate.yanked = false)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/index/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub struct CrateVersion {
pub features: HashMap<String, Vec<String>>,

/// Is the crate yanked.
pub yanked: Option<bool>,
#[serde(skip_serializing_if = "std::ops::Not::not", default)]
pub yanked: bool,

/// Is the crate yanked.
#[serde(skip_serializing_if = "Option::is_none", default)]
Expand Down