Skip to content

Commit

Permalink
Auto merge of #44913 - leavehouse:patch-1, r=BurntSushi
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 7, 2017
2 parents d2f71bf + 6482ee7 commit bb4d149
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ impl TcpStream {
/// # Examples
///
/// ```no_run
/// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpStream};
/// use std::net::{IpAddr, Ipv4Addr, TcpStream};
///
/// let stream = TcpStream::connect("127.0.0.1:8080")
/// .expect("Couldn't connect to the server...");
/// assert_eq!(stream.local_addr().unwrap(),
/// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080)));
/// assert_eq!(stream.local_addr().unwrap().ip(),
/// IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn local_addr(&self) -> io::Result<SocketAddr> {
Expand Down

0 comments on commit bb4d149

Please sign in to comment.