about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjD91mZM2 <me@krake.one>2018-07-07 06:52:03 +0200
committerjD91mZM2 <me@krake.one>2018-07-07 06:52:03 +0200
commitc007a78d23b684b8edaf624a93ec2d0579a37a86 (patch)
tree61fa9d0f921a2694acfffcf1310cde1d127579a1
parentabac5e722f3786fe2692bde9ab626afb25dd02de (diff)
downloadrust-c007a78d23b684b8edaf624a93ec2d0579a37a86.tar.gz
rust-c007a78d23b684b8edaf624a93ec2d0579a37a86.zip
Add is_unnamed
-rw-r--r--src/libstd/sys/redox/ext/net.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libstd/sys/redox/ext/net.rs b/src/libstd/sys/redox/ext/net.rs
index d29d28c8427..4c5f8574621 100644
--- a/src/libstd/sys/redox/ext/net.rs
+++ b/src/libstd/sys/redox/ext/net.rs
@@ -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 {