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

feat: Adding Sink trait impl to Either #6239

Merged
merged 6 commits into from
Dec 22, 2023

Conversation

mobley-trent
Copy link
Contributor

Closes #6181

Motivation

Solution

tokio-util/src/either.rs Outdated Show resolved Hide resolved
@Darksonn Darksonn added A-tokio-util Area: The tokio-util crate M-io Module: tokio/io labels Dec 22, 2023
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
{
type Error = Error;

fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

In each method, you need this:

Suggested change
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {

Right now, you're using std::io::Error instead, which is the wrong error type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do I fix it ?

@mobley-trent
Copy link
Contributor Author

Hey @Darksonn should the return type be Result<(), Error> or Result<(), Self::Error> ?
Also I think Error should be instantiated to L::Error instead of just error. What are your thoughts ?

@Darksonn
Copy link
Contributor

All of Error, Self::Error, L::Error, R::Error refer to the same type. I would prefer that you use the first one.

You probably have to explicitly say std::result::Result because the std::io::Result type alias does not seem to allow you to specify the error type.

@mobley-trent mobley-trent marked this pull request as ready for review December 22, 2023 16:55
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.

Thank you.

@Darksonn Darksonn merged commit 53ad102 into tokio-rs:master Dec 22, 2023
71 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.

Add Sink trait impl to Either
2 participants