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

Provide length when serializing sequence #571

Merged

Conversation

stephaneyfx
Copy link
Contributor

Some serializers (e.g. bincode) require a length to serialize a sequence. This code does what iterator_len_hint does (called by collect_seq in serde).

Resolves #570

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #571 (0a27e24) into master (d62e486) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #571   +/-   ##
=======================================
  Coverage   44.41%   44.41%           
=======================================
  Files          40       40           
  Lines        3249     3249           
=======================================
  Hits         1443     1443           
  Misses       1806     1806           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jonasbb
Copy link
Owner

jonasbb commented Mar 10, 2023

Hi, thanks for the PR. The correct fix is to revert #566. I am already on it. I would like to use your test case, since bincode is not a dev-dependency. If you remove the changes to serde_with/src/ser/impls.rs I can merge it after the revert.

bors bot added a commit that referenced this pull request Mar 10, 2023
572: Revert a breaking change to the Seq trait bound r=jonasbb a=jonasbb

The code released in #566 broke multiple thing. It broke compatability with bincode #570 and #571.

It broke this atribute combination:

```rust
 #[serde_as(as = "Seq<(_, Vec<_>)>")]
BTreeMap<usize, Vec<usize>>,
```

```
error[E0277]: the trait bound `serde_with::Seq<(serde_with::Same, std::vec::Vec<serde_with::Same>)>: serde_with::SerializeAs<_>` is not satisfied
```

bors r+

Co-authored-by: Jonas Bushart <jonas@bushart.org>
@stephaneyfx
Copy link
Contributor Author

Sounds good. Thank you. I will merge in your changes and remove my fix to keep only the test case.

Some serializers (e.g. bincode) require a length to serialize a sequence. This test verifies that mapping a map to a sequence when serializing provides the length to the serializer.

For jonasbb#570
@stephaneyfx stephaneyfx force-pushed the provide-length-when-serializing-seq branch from 2e1c687 to 0a27e24 Compare March 10, 2023 23:03
@stephaneyfx
Copy link
Contributor Author

Unless I messed up something, this PR should now contain only the test as requested.

@jonasbb
Copy link
Owner

jonasbb commented Mar 10, 2023

Thank you. This looks good.

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 10, 2023

Build succeeded:

@bors bors bot merged commit 38f638f into jonasbb:master Mar 10, 2023
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.

2.3.0 breaks HashMap serialization as Vec of pairs with bincode
2 participants