Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change private bounds from R: Read to R: BufRead #453

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Feb 12, 2025

Reasons to do this:

  • This matches the stronger bounds of all callers
  • Calling these functions with a R that is not a buffered reader would cause performance issues. These functions call .bytes() on the reader which will perform very small reads.
  • There will soon be a clippy lint that produces a warning on this code. New lint: unbuffered_bytes rust-clippy#14089
  • These are not public functions so this is not a breaking change.

@JonathanBrouwer JonathanBrouwer changed the title Change internal bounds from R: Read to R: BufRead Change private bounds from R: Read to R: BufRead Feb 12, 2025
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! That's a great catch and it will prevent the performance issues you mentioned.

It's good these functions aren't public as well, making this PR an easy merge.

@Byron Byron merged commit cdae651 into rust-lang:main Feb 13, 2025
14 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants