Skip to content

Commit bb4d149

Browse files
committedOct 7, 2017
Auto merge of #44913 - leavehouse:patch-1, r=BurntSushi
Fix TcpStream::local_addr docs example code The local address's port is not 8080 in this example, that's the remote peer address port. On my machine, the local address is different every time, so I've changed `assert_eq` to only test the IP address
2 parents d2f71bf + 6482ee7 commit bb4d149

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/libstd/net/tcp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ impl TcpStream {
194194
/// # Examples
195195
///
196196
/// ```no_run
197-
/// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpStream};
197+
/// use std::net::{IpAddr, Ipv4Addr, TcpStream};
198198
///
199199
/// let stream = TcpStream::connect("127.0.0.1:8080")
200200
/// .expect("Couldn't connect to the server...");
201-
/// assert_eq!(stream.local_addr().unwrap(),
202-
/// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080)));
201+
/// assert_eq!(stream.local_addr().unwrap().ip(),
202+
/// IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
203203
/// ```
204204
#[stable(feature = "rust1", since = "1.0.0")]
205205
pub fn local_addr(&self) -> io::Result<SocketAddr> {

0 commit comments

Comments
 (0)