File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -34,18 +34,22 @@ use sys::tcp::TcpAcceptor as TcpAcceptorImp;
34
34
/// A structure which represents a TCP stream between a local socket and a
35
35
/// remote socket.
36
36
///
37
+ /// The socket will be closed when the value is dropped.
38
+ ///
37
39
/// # Example
38
40
///
39
41
/// ```no_run
40
- /// # #![allow(unused_must_use)]
41
42
/// use std::io::TcpStream;
42
43
///
43
- /// let mut stream = TcpStream::connect("127.0.0.1:34254");
44
+ /// {
45
+ /// let mut stream = TcpStream::connect("127.0.0.1:34254");
46
+ ///
47
+ /// // ignore the Result
48
+ /// let _ = stream.write(&[1]);
44
49
///
45
- /// stream.write(&[1]);
46
- /// let mut buf = [0];
47
- /// stream.read(&mut buf);
48
- /// drop(stream); // close the connection
50
+ /// let mut buf = [0];
51
+ /// let _ = stream.read(&mut buf); // ignore here too
52
+ /// } // the stream is closed here
49
53
/// ```
50
54
pub struct TcpStream {
51
55
inner : TcpStreamImp ,
You can’t perform that action at this time.
0 commit comments