net: implement AsRef<Self> for TcpStream and UnixStream (#7573)

This commit is contained in:
Aatif Syed 2025-09-04 11:31:49 +01:00 committed by GitHub
parent 37ca2f049c
commit d1e06f831e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -1462,6 +1462,12 @@ impl fmt::Debug for TcpStream {
}
}
impl AsRef<Self> for TcpStream {
fn as_ref(&self) -> &Self {
self
}
}
#[cfg(unix)]
mod sys {
use super::TcpStream;

View File

@ -1076,6 +1076,12 @@ impl fmt::Debug for UnixStream {
}
}
impl AsRef<Self> for UnixStream {
fn as_ref(&self) -> &Self {
self
}
}
impl AsRawFd for UnixStream {
fn as_raw_fd(&self) -> RawFd {
self.io.as_raw_fd()