Skip to content

Add serde support#55

Merged
bluss merged 4 commits into
bluss:masterfrom
daboross:serde
Jul 30, 2017
Merged

Add serde support#55
bluss merged 4 commits into
bluss:masterfrom
daboross:serde

Conversation

@daboross

@daboross daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

This implements serde support under the optional 'serde' feature, and adds unit tests to test said support.

Serde will be optionally included for runtime, but is unfortunately required for running tests - as cargo does not have support for optional dev-dependencies. FEATURES="serde" is added to the travis config, as serde-support tests will not run without it.

Fixes #54.

…rayString.

This implements serde support under the optional 'serde' feature, and adds unit tests to test said support.
https://serde.rs/unit-testing.html used as a guide for the unit tests - using 'serde_test' makes for much
less boilerplate here, but it does require that the project have a non-optional dev dependency on 'serde_test'.
@daboross

daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

Sorry about that - removed usages of '?' in the code.

@daboross

daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

@bluss Should I re-make this PR towards the 0.3 branch instead?

@daboross daboross mentioned this pull request Jun 8, 2017
@bluss

bluss commented Jun 8, 2017

Copy link
Copy Markdown
Owner

Hm probably not. We should aim forwards.

I'm thinking here I'd prefer if the feature flag was versioned and had a separate name from the crate. So a feature name like serde-1 or use_serde would sit better. I guess the standard is just "serde" but I've seen crates where that is a problem.

@daboross

daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

@bluss Ah, just missed the comment! I had just filed a PR for the 0.3 branch, but it seems it fails anyways with the rust 1.2.0 support.

I was basing the serde name off of https://github.com/brson/rust-api-guidelines/blob/master/README.md#data-structures-implement-serdes-serialize-deserialize-c-serde, which states that the feature should be the crate name itself.

edit: Correction, what I meant to link was https://github.com/brson/rust-api-guidelines/blob/master/README.md#crate-has-a-serde-cfg-option-that-enables-serde-c-serde-cfg, right below what I linked above.

@bluss

bluss commented Jun 8, 2017

Copy link
Copy Markdown
Owner

Thanks for the link, I don't think it's that simple, even though it's a neat solution for that particular issue. It's time to break the feature and optional crate namespace merge. Using the crate name limits options when it comes to the evolution of the crate and avoiding breaking changes.

@bluss

bluss commented Jun 8, 2017

Copy link
Copy Markdown
Owner

I for example think that ndarray 0.9, which supports serde 0.9, it could have added support for serde 1.0 without breaking change if it had the foresight.

@daboross

daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

Ah, that makes sense. I wasn't sure if depending on multiple versions of a crate would be possible even under different optional features. serde-1 is good then?

@bluss

bluss commented Jun 8, 2017

Copy link
Copy Markdown
Owner

Right -- it's not straightforward to do such a dependency. But the start of it exists 😄 as legacy-serde. Maybe the idea is not fully matured.

I think serde-1 is the way to go.

@daboross

daboross commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

Sounds good then! Feature name updated.

@ahicks92 ahicks92 mentioned this pull request Jun 11, 2017
@dtolnay

dtolnay commented Jun 11, 2017

Copy link
Copy Markdown

If you are versioning the feature to possibly support multiple Serde versions in the same arrayvec in the future, I would prefer to standardize on the official shims. Add a dependency on serde1 and implement serde1::{Serialize, Deserialize}. That way no implicit "serde" feature is inferred by Cargo.

Comment thread src/array_string.rs Outdated
type Value = ArrayString<A>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a string with no more than {} elements", A::capacity())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The word "element" of a string is unclear to me. Is this terminology used elsewhere in arrayvec? I would prefer to say "a string of no more than {} bytes".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, that makes more sense.

@daboross

Copy link
Copy Markdown
Contributor Author

Thank you for the comment about the messages @dtolnay, I think the string message was really just copy-pasted from the ArrayVec one. Should be more clear now!

@daboross

daboross commented Jun 15, 2017

Copy link
Copy Markdown
Contributor Author

@bluss thoughts on depending on serde1 vs. serde under a serde-1 feature?

Edit: I mean I'd be OK with either, and I can update this PR to whichever you'd choose for the project.

Thanks to @camlorn for the idea.
@daboross

Copy link
Copy Markdown
Contributor Author

Just added failure tests, thanks to #58 for the idea.

P.S. Sorry, ignore my last comment - I just had a bug in the test code I wrote.

@alexbool

Copy link
Copy Markdown

@bluss friendly ping

@bluss

bluss commented Jul 30, 2017

Copy link
Copy Markdown
Owner

Well, I'm certainly being unfriendly by not being on top of this. (Not guaranteed to be here at any one particular month of the year, but some of them would be nice...) Let's see..

@bluss

bluss commented Jul 30, 2017

Copy link
Copy Markdown
Owner

Comaintainers / maintainers that are interested in taking care of this crate? I'm not planning on stepping down, but I clearly don't have enough time to do the whole job.

@bluss
bluss merged commit 2949720 into bluss:master Jul 30, 2017
@bluss

bluss commented Jul 30, 2017

Copy link
Copy Markdown
Owner

Many thanks for the PR

@bluss

bluss commented Jul 31, 2017

Copy link
Copy Markdown
Owner

Features are in a deadlock in arrayvec, since the 0.3 branch says the version requirement is Rust 1.2.0. Ridiculous, sure. So we can't release any new features on that branch. (Master already tests from newer versions in travis.)

Hoping to resolve all the planned API changes for the next version and release 0.4. It's not ideal, but the issues are pretty long standing as well.

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.

4 participants