From 534fd3a98349ec2250e1515a3cb19dbb98935b98 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 9 Nov 2014 15:23:56 -0500 Subject: [PATCH] Don't call drop in tcpstream docs This suggests that you must call it, which is normally not what you want to do. --- src/libstd/io/net/tcp.rs | 16 ++++++++++------ 1 file 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"); /// -/// stream.write(&[1]); -/// let mut buf = [0]; -/// stream.read(&mut buf); -/// drop(stream); // close the connection +/// // ignore the Result +/// let _ = stream.write(&[1]); +/// +/// let mut buf = [0]; +/// let _ = stream.read(&mut buf); // ignore here too +/// } // the stream is closed here /// ``` pub struct TcpStream { inner: TcpStreamImp,