File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,33 @@ impl SocketAddr {
6767 pub fn as_pathname ( & self ) -> Option < & Path > {
6868 None
6969 }
70+
71+ /// Returns true if and only if the address is unnamed.
72+ ///
73+ /// # Examples
74+ ///
75+ /// A named address:
76+ ///
77+ /// ```no_run
78+ /// use std::os::unix::net::UnixListener;
79+ ///
80+ /// let socket = UnixListener::bind("/tmp/sock").unwrap();
81+ /// let addr = socket.local_addr().expect("Couldn't get local address");
82+ /// assert_eq!(addr.is_unnamed(), false);
83+ /// ```
84+ ///
85+ /// An unnamed address:
86+ ///
87+ /// ```
88+ /// use std::os::unix::net::UnixDatagram;
89+ ///
90+ /// let socket = UnixDatagram::unbound().unwrap();
91+ /// let addr = socket.local_addr().expect("Couldn't get local address");
92+ /// assert_eq!(addr.is_unnamed(), true);
93+ /// ```
94+ pub fn is_unnamed ( & self ) -> bool {
95+ false
96+ }
7097}
7198impl fmt:: Debug for SocketAddr {
7299 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
You can’t perform that action at this time.
0 commit comments