Skip to content

Commit 7f9e653

Browse files
authored
Fix TcpStream::local_addr 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
1 parent 3c96d40 commit 7f9e653

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/net/tcp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ impl 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)