Skip to content

Commit

Permalink
Document UdpSocket peer_addr NotConnected error
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU committed Mar 12, 2019
1 parent df2dce3 commit 54bf8e0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 54bf8e0

Please sign in to comment.