Document UdpSocket peer_addr NotConnected error
This commit is contained in:
parent
bf473e3c15
commit
24e3fa079c
1 changed files with 13 additions and 0 deletions
|
@ -193,6 +193,19 @@ impl UdpSocket {
|
|||
/// assert_eq!(socket.peer_addr().unwrap(),
|
||||
/// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203)));
|
||||
/// ```
|
||||
///
|
||||
/// If the socket isn't connected, it will return a [`NotConnected`] error.
|
||||
///
|
||||
/// [`NotConnected`]: ../../std/io/enum.ErrorKind.html#variant.NotConnected
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(udp_peer_addr)]
|
||||
/// use std::net::UdpSocket;
|
||||
///
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
|
||||
/// assert_eq!(socket.peer_addr().unwrap_err().kind(),
|
||||
/// ::std::io::ErrorKind::NotConnected);
|
||||
/// ```
|
||||
#[unstable(feature = "udp_peer_addr", issue = "59127")]
|
||||
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
||||
self.0.peer_addr()
|
||||
|
|
Loading…
Reference in a new issue