]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #25078 - nham:std_net_impl_debug, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 4 May 2015 17:12:19 +0000 (17:12 +0000)
committerbors <bors@rust-lang.org>
Mon, 4 May 2015 17:12:19 +0000 (17:12 +0000)
I'm uncertain whether the 3 implementations in `net2` should unwrap the socket address values. Without unwrapping it looks like this:

```
UdpSocket { addr: Ok(V4(127.0.0.1:34354)), inner: 3 }
TcpListener { addr: Ok(V4(127.0.0.1:9123)), inner: 4 }
TcpStream { addr: Ok(V4(127.0.0.1:9123)), peer: Ok(V4(127.0.0.1:58360)), inner: 5 }
```

One issue is that you can create, e.g. `UdpSocket`s with bad addresses, which means you can't just unwrap in the implementation:

```
#![feature(from_raw_os)]
use std::net::UdpSocket;
use std::os::unix::io::FromRawFd;

let sock: UdpSocket = unsafe { FromRawFd::from_raw_fd(-1) };
println!("{:?}", sock); // prints "UdpSocket { addr: Err(Error { repr: Os(9) }), inner: -1 }"

```

Fixes #23134.


Trivial merge