Skip to content

Conversation

@aatifsyed
Copy link
Contributor

Motivation

I'm writing a wrapper that I want to work for OwnedReadHalf and TcpStream.
OwnedReadHalf: AsRef<TcpStream> already, so this helps.

Solution

TcpStream: AsRef<Self>

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Sep 4, 2025
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.

Hmm. Initially I was going to say no to this, but it seems that the stdlib documentation says that libraries should add this kind of impl for AsRef, so I'm going to accept it.

However, please add the AsRef impl to other types with owned read/write halves such as UnixStream too.

@aatifsyed
Copy link
Contributor Author

Thanks for your review, I've made the requested changes :)

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 changed the title net: TcpStream: AsRef<Self> net: implement AsRef<Self> for TcpStream and UnixStream Sep 4, 2025
@Darksonn Darksonn enabled auto-merge (squash) September 4, 2025 10:28
@Darksonn Darksonn merged commit d1e06f8 into tokio-rs:master Sep 4, 2025
90 checks passed
@Darksonn Darksonn mentioned this pull request Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate M-net Module: tokio/net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants