-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
Rewrite: seperated Decode and BorrowDecode #526
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.
|
e4962bd
to
f49c9e6
Compare
Will this require anyone who implements |
They should implement both, but it's not enforced in the type system. I'm not sure if we should considering it an error |
Some cases we should test: |
There are a number of issues with the current design where
Decode
depends 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
Decode
andBorrowDecode
to be completely separate.Some notes:
impl_borrow_decode
macro that is publicly available, which can be used to automatically deriveBorrowDecode
for 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
Decode
manually. Otherwise it should hopefully be a painless change.