Open
Conversation
Since `&'a mut R` is `Read` (or `Write`) when `R` is `Read` (resp. `Write`), there is no need to depend on `<R: ?Sized + Read> &'a mut R` over just plain `<R: Read> R`. The caller can still instantiate `R = &'a mut R_` when a reference is desired (and indeed this is done here for e.g. `MapDeserializer`).
bmwill
reviewed
Apr 18, 2026
Comment on lines
+73
to
75
| pub fn serialize_into<T>(mut write: impl std::io::Write, value: &T) -> Result<()> | ||
| where | ||
| W: ?Sized + std::io::Write, | ||
| T: ?Sized + Serialize, |
There was a problem hiding this comment.
I think losing the W: ?Sized bound is a real functional loss right? trait objects would no longer be usable via this api.
Contributor
Author
There was a problem hiding this comment.
Mmm good question. Let me check
bmwill
reviewed
Apr 18, 2026
Comment on lines
+157
to
+160
| impl<R> Deserializer<R> { | ||
| /// Creates a new `Deserializer` which will be deserializing the provided | ||
| /// input. | ||
| fn new(input: &'de [u8], max_remaining_depth: usize) -> Self { | ||
| fn new(input: R, max_remaining_depth: usize) -> Self { |
There was a problem hiding this comment.
Not something that we really need to deal with right now but it would be interesting if we could restructure this crate to be able to operate in no_std environments since afaik the only usage of std we really have today is via the std::io traits
bmwill
reviewed
Apr 18, 2026
Comment on lines
+83
to
+84
| pub fn serialize_into_with_limit<T>( | ||
| mut write: impl std::io::Write, |
There was a problem hiding this comment.
yeah i would probably keep the generic bounds but we could have this just be W instead of &mut W
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bringing back #9 from @Twey
Summary
Since
&'a mut RisRead(orWrite) whenRisRead(resp.Write), there is no need to depend on<R: ?Sized + Read> &'a mut Rover just plain<R: Read> R. The caller can still instantiateR = &'a mut R_when a reference is desired (and indeed this is done here for e.g.MapDeserializer).