about summary refs log tree commit diff
path: root/src/libstd/io/net/tcp.rs
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2014-11-09 15:23:56 -0500
committerSteve Klabnik <steve@steveklabnik.com>2014-11-24 15:22:55 -0500
commit534fd3a98349ec2250e1515a3cb19dbb98935b98 (patch)
tree26340fee76ed6caf8a1f5cd154ada84f25364d47 /src/libstd/io/net/tcp.rs
parent377d7524a897ae91dfd48e7e34847af88dac49cb (diff)
downloadrust-534fd3a98349ec2250e1515a3cb19dbb98935b98.tar.gz
rust-534fd3a98349ec2250e1515a3cb19dbb98935b98.zip
Don't call drop in tcpstream docs
This suggests that you must call it, which is normally not what you want to do.
Diffstat (limited to 'src/libstd/io/net/tcp.rs')
-rw-r--r--src/libstd/io/net/tcp.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index cab54d82e1c..cbac6b48b83 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -34,18 +34,22 @@ use sys::tcp::TcpAcceptor as TcpAcceptorImp;
 /// A structure which represents a TCP stream between a local socket and a
 /// remote socket.
 ///
+/// The socket will be closed when the value is dropped.
+///
 /// # Example
 ///
 /// ```no_run
-/// # #![allow(unused_must_use)]
 /// use std::io::TcpStream;
 ///
-/// let mut stream = TcpStream::connect("127.0.0.1:34254");
+/// {
+///     let mut stream = TcpStream::connect("127.0.0.1:34254");
+///
+///     // ignore the Result
+///     let _ = stream.write(&[1]);
 ///
-/// stream.write(&[1]);
-/// let mut buf = [0];
-/// stream.read(&mut buf);
-/// drop(stream); // close the connection
+///     let mut buf = [0];
+///     let _ = stream.read(&mut buf); // ignore here too
+/// } // the stream is closed here
 /// ```
 pub struct TcpStream {
     inner: TcpStreamImp,