Skip to content

Commit 67c2c29

Browse files
committed
Merge pull request #1013 from servo/try_clone
Replace duplicate() by try_clone() in std::net.
2 parents 037fe59 + 88a9dbb commit 67c2c29

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

text/0517-io-os-reform.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ impl TcpStream {
16081608
fn peer_addr(&self) -> io::Result<SocketAddr>;
16091609
fn local_addr(&self) -> io::Result<SocketAddr>;
16101610
fn shutdown(&self, how: Shutdown) -> io::Result<()>;
1611-
fn duplicate(&self) -> io::Result<TcpStream>;
1611+
fn try_clone(&self) -> io::Result<TcpStream>;
16121612
}
16131613

16141614
impl Read for TcpStream { ... }
@@ -1619,8 +1619,8 @@ impl<'a> Write for &'a TcpStream { ... }
16191619
#[cfg(windows)] impl AsRawSocket for TcpStream { ... }
16201620
```
16211621

1622-
* `clone` has been replaced with a `duplicate` function. The implementation of
1623-
`duplicate` will map to using `dup` on Unix platforms and
1622+
* `clone` has been replaced with a `try_clone` function. The implementation of
1623+
`try_clone` will map to using `dup` on Unix platforms and
16241624
`WSADuplicateSocket` on Windows platforms. The `TcpStream` itself will no
16251625
longer be reference counted itself under the hood.
16261626
* `close_{read,write}` are both removed in favor of binding the `shutdown`
@@ -1646,7 +1646,7 @@ into the `TcpListener` structure. Specifically, this will be the resulting API:
16461646
impl TcpListener {
16471647
fn bind<A: ToSocketAddrs>(addr: &A) -> io::Result<TcpListener>;
16481648
fn local_addr(&self) -> io::Result<SocketAddr>;
1649-
fn duplicate(&self) -> io::Result<TcpListener>;
1649+
fn try_clone(&self) -> io::Result<TcpListener>;
16501650
fn accept(&self) -> io::Result<(TcpStream, SocketAddr)>;
16511651
fn incoming(&self) -> Incoming;
16521652
}
@@ -1663,7 +1663,7 @@ Some major changes from today's API include:
16631663

16641664
* The static distinction between `TcpAcceptor` and `TcpListener` has been
16651665
removed (more on this in the [socket][Sockets] section).
1666-
* The `clone` functionality has been removed in favor of `duplicate` (same
1666+
* The `clone` functionality has been removed in favor of `try_clone` (same
16671667
caveats as `TcpStream`).
16681668
* The `close_accept` functionality is removed entirely. This is not currently
16691669
implemented via `shutdown` (not supported well across platforms) and is
@@ -1690,7 +1690,7 @@ impl UdpSocket {
16901690
fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)>;
16911691
fn send_to<A: ToSocketAddrs>(&self, buf: &[u8], addr: &A) -> io::Result<usize>;
16921692
fn local_addr(&self) -> io::Result<SocketAddr>;
1693-
fn duplicate(&self) -> io::Result<UdpSocket>;
1693+
fn try_clone(&self) -> io::Result<UdpSocket>;
16941694
}
16951695

16961696
#[cfg(unix)] impl AsRawFd for UdpSocket { ... }
@@ -1705,7 +1705,7 @@ Some important points of note are:
17051705
`#[unstable]` for now.
17061706
* All timeout support is removed. This may come back in the form of `setsockopt`
17071707
(as with TCP streams) or with a more general implementation of `select`.
1708-
* `clone` functionality has been replaced with `duplicate`.
1708+
* `clone` functionality has been replaced with `try_clone`.
17091709

17101710
The `UdpSocket` type will adhere to both `Send` and `Sync`.
17111711

0 commit comments

Comments
 (0)