This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Rewrite: seperated Decode and BorrowDecode#526
Merged
VictorKoenders merged 16 commits intotrunkfrom Jun 4, 2022
Merged
Conversation
7aaf3b3 to
eca4ab2
Compare
Codecov Report
@@ Coverage Diff @@
## trunk #526 +/- ##
==========================================
- Coverage 55.33% 54.52% -0.82%
==========================================
Files 48 49 +1
Lines 4223 4422 +199
==========================================
+ Hits 2337 2411 +74
- Misses 1886 2011 +125
Continue to review full report at Codecov.
|
This was referenced Apr 1, 2022
e4962bd to
f49c9e6
Compare
|
Will this require anyone who implements |
Contributor
Author
|
They should implement both, but it's not enforced in the type system. I'm not sure if we should considering it an error |
Contributor
Author
|
Some cases we should test:
|
ghost
reviewed
Apr 4, 2022
This was
linked to
issues
Apr 8, 2022
ghost
suggested changes
May 21, 2022
ghost
approved these changes
Jun 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are a number of issues with the current design where
Decodedepends onBorrowDecode. The most obvious one is the implementation ofCow.Ideally we'd want:
But this is currently not possible.
This issue happens with other containers types as well. One issue is
Arc<str>(#527), becauseArc<T>requiresT: Decode.This pull request splits the implementation of
DecodeandBorrowDecodeto be completely separate.Some notes:
impl_borrow_decodemacro that is publicly available, which can be used to automatically deriveBorrowDecodefor any type that implementsDecode#[derive(Decode)]now implies#[derive(BorrowDecode)]automatically.As far as I can tell this is only a breaking change for people who implement
Decodemanually. Otherwise it should hopefully be a painless change.