Skip to content

der: simplify Header::peek and Tag::peek #1886

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

Merged
merged 1 commit into from
Jun 21, 2025
Merged

Conversation

tarcieri
Copy link
Member

We can rely on the ability to clone the Reader to use the Decode implementation to implement peeking, so we don't need a separate bespoke implementation.

This also avoids losing the Reader context while peeking.

We can rely on the ability to clone the `Reader` to use the `Decode`
implementation to implement peeking, so we don't need a separate bespoke
implementation.

This also avoids losing the `Reader` context while peeking.
@tarcieri tarcieri force-pushed the der/simplified-peeking branch from 3644522 to 70a4f16 Compare June 21, 2025 16:18
@tarcieri tarcieri merged commit 0f4ce04 into master Jun 21, 2025
107 checks passed
@tarcieri tarcieri deleted the der/simplified-peeking branch June 21, 2025 16:39
@dishmaker
Copy link
Contributor

Ah, so peek_optional on EOF just simplifies to reader.is_finished()

@tarcieri
Copy link
Member Author

It was only used in a couple places.

If it were used in more, perhaps it could be brought back as a Decode impl on Option<Tag> (provided the trait bounds don't conflict)

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 participants