Skip to content

Commit c007a78

Browse files
committed
Add is_unnamed
1 parent abac5e7 commit c007a78

File tree

1 file changed

+27
-0
lines changed
  • src/libstd/sys/redox/ext

1 file changed

+27
-0
lines changed

src/libstd/sys/redox/ext/net.rs

+27
Original file line numberDiff line numberDiff 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
}
7198
impl fmt::Debug for SocketAddr {
7299
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

0 commit comments

Comments
 (0)