Skip to content

Conversation

@ehuss
Copy link
Contributor

@ehuss ehuss commented Jan 5, 2019

This is to help assist with stabilizing alternative registries.

The registry field could use a URL type (with url and url_serde crates) if you want it to be more strictly typed (ala #59).

@oli-obk
Copy link
Owner

oli-obk commented Jan 9, 2019

Please make all of the new fields #[serde(default)] so it doesn't break using a newer cargo_metadata version for older compilers


/// A target platform.
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Platform(String);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be #[serde(transparent)]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I don't understand the difference. What does transparent do that the normal newtype struct doesn't do?

Copy link
Contributor

Choose a reason for hiding this comment

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

For JSON there's no difference I think, but some data formats may include the name for unit-structs, which is exposed for non-transparent wrappers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. It also generates less code, which seems nice.

@ehuss
Copy link
Contributor Author

ehuss commented Jan 9, 2019

Please make all of the new fields #[serde(default)] so it doesn't break using a newer cargo_metadata version for older compilers

I'm a little confused. Isn't that the default behavior for Option types? They are set to None if not present?

@oli-obk
Copy link
Owner

oli-obk commented Jan 9, 2019

Isn't that the default behavior for Option types

I don't think so. But since you are mentioning it, a test would be great ;)

@ehuss
Copy link
Contributor Author

ehuss commented Jan 10, 2019

I've updated with a new test suite. I can split that off into a separate PR, if you'd like. In the past I have missed having a way to test things, so maybe this can establish a way to ensure everything works. Hopefully it's ok? It actually helped exposed a bug in either cargo or cargo_metadata (rust-lang/cargo#6534 — I'm hoping to just fix it in Cargo).

@oli-obk oli-obk merged commit 8897b2d into oli-obk:master Jan 11, 2019
@oli-obk
Copy link
Owner

oli-obk commented Jan 11, 2019

Absolutely wonderful! Thanks

@matklad
Copy link
Contributor

matklad commented Jan 11, 2019

@oli-obk I'd appreciate a release 😉

@oli-obk
Copy link
Owner

oli-obk commented Jan 14, 2019

ups, done

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants