Conversation
kskalski
reviewed
Mar 10, 2026
| /// Errors if fewer than `N` bytes are available. | ||
| #[inline] | ||
| #[expect(deprecated)] | ||
| fn peek_array<const N: usize>(&mut self) -> ReadResult<&[u8; N]> { |
Contributor
There was a problem hiding this comment.
So it's only a rename.
I'm thinking, maybe we should make both peek_byte and peek_array return value instead of borrowing?
Contributor
Author
There was a problem hiding this comment.
For peek_byte, definitely makes sense to return by value since a byte is smaller than a pointer. But, for peek_array I think it's reasonable to let the caller decide whether to dereference based on N
kskalski
approved these changes
Mar 11, 2026
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.
Following the conversation from #220, this keeps most of the deprecations from #216, but keeps a subset of buffer-implicit methods. Specifically, we have observed that there are various cases where either
peekorfill_arraycan significantly simplify manualSchemaReadimplementations.This PR adds the following methods in an effort to unify
Readermethod naming:peek_byte- In favor of deprecatedpeekpeek_array- In favor of deprecatedfill_arrayconsumeandconsume_uncheckedare no longer deprecated, as they are necessary counterparts to the peek methods.All other deprecatations and method renames from #216 are preserved.
The result of this in v0.5 will be a
Readerthat is less burdensome to implement for io-buffer backends, while still preserving minimal buffering functionality to ease manualSchemaReadimplementations.If we ultimately decide against the context system proposed in #220, this is likely the route forward for now.