]> git.lizzy.rs Git - rust.git/commitdiff
Add is_unnamed
authorjD91mZM2 <me@krake.one>
Sat, 7 Jul 2018 04:52:03 +0000 (06:52 +0200)
committerjD91mZM2 <me@krake.one>
Sat, 7 Jul 2018 04:52:03 +0000 (06:52 +0200)
src/libstd/sys/redox/ext/net.rs

index d29d28c8427d07e899d23955b3153a5c0b585757..4c5f857462193ddf51dc2eb630eb4c882358e0af 100644 (file)
@@ -67,6 +67,33 @@ impl SocketAddr {
     pub fn as_pathname(&self) -> Option<&Path> {
         None
     }
+
+    /// Returns true if and only if the address is unnamed.
+    ///
+    /// # Examples
+    ///
+    /// A named address:
+    ///
+    /// ```no_run
+    /// use std::os::unix::net::UnixListener;
+    ///
+    /// let socket = UnixListener::bind("/tmp/sock").unwrap();
+    /// let addr = socket.local_addr().expect("Couldn't get local address");
+    /// assert_eq!(addr.is_unnamed(), false);
+    /// ```
+    ///
+    /// An unnamed address:
+    ///
+    /// ```
+    /// use std::os::unix::net::UnixDatagram;
+    ///
+    /// let socket = UnixDatagram::unbound().unwrap();
+    /// let addr = socket.local_addr().expect("Couldn't get local address");
+    /// assert_eq!(addr.is_unnamed(), true);
+    /// ```
+    pub fn is_unnamed(&self) -> bool {
+        false
+    }
 }
 impl fmt::Debug for SocketAddr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {