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
This commit is contained in:
parent
3c96d40d32
commit
7f9e653a29
1 changed files with 2 additions and 2 deletions
|
|
@ -198,8 +198,8 @@ impl 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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue