Skip to content
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

io: fix trait bounds on impl Sink for StreamReader #6647

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

eric-seppanen
Copy link
Contributor

This impl had a bound on StreamReader<S, E>; this is incorrect because the second generic parameter to StreamReader is not an error type; it's a buffer type.

Motivation

This "passthrough" Sink impl is currently unusable because it requires the Sink error type be the same as the StreamReader buffer type. This seems like it must have been a typo, because that constraint is not useful.

See the example program in #6642 for more details.

Solution

Resolve this by removing the constraint on StreamReader's buffer type B. It's irrelevant to a Sink impl anyway.

Fixes #6642.

This impl had a bound on `StreamReader<S, E>`; this is incorrect
because:
- The second generic parameter to `StreamReader` is not an error type;
  it's a buffer type.
- The `Stream` error type in `StreamReader` should not need to be the
  same as the `Sink` error type.

This "passthrough" `Sink` impl was effectively unusable because it
required the `Sink` error type be the same as the `StreamReader` buffer
type.

Resolve this by allowing the `StreamReader` buffer to be anything in
this impl.
@mox692 mox692 added A-tokio-util Area: The tokio-util crate M-io Module: tokio/io labels Jun 21, 2024
Copy link
Member

@mox692 mox692 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn merged commit ed4ddf4 into tokio-rs:master Jun 21, 2024
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-io Module: tokio/io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio_util::io::StreamReader uses incorrect generic parameter for Sink impl
3 participants