Skip to content

Commit 70175c4

Browse files
committed
Converts AddressFamily to struct with associated consts
1 parent e13a182 commit 70175c4

File tree

9 files changed

+572
-371
lines changed

9 files changed

+572
-371
lines changed

changelog/2210.added.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added more `AddressFamily` variants.

changelog/2210.changed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Converted `AddressFamily` to struct with associated constants to support vendor-defined address families.

examples/getifaddrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
let family = addr
3030
.address
3131
.as_ref()
32-
.and_then(SockaddrStorage::family)
32+
.map(SockaddrStorage::family)
3333
.map(|af| format!("{:?}", af))
3434
.unwrap_or("".to_owned());
3535
match (

src/ifaddrs.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,10 @@ mod tests {
200200
} else {
201201
continue;
202202
};
203-
if sock.family() == Some(crate::sys::socket::AddressFamily::Inet) {
203+
if sock.family() == crate::sys::socket::AddressFamily::INET {
204204
let _ = sock.as_sockaddr_in().unwrap();
205205
return;
206-
} else if sock.family()
207-
== Some(crate::sys::socket::AddressFamily::Inet6)
206+
} else if sock.family() == crate::sys::socket::AddressFamily::INET6
208207
{
209208
let _ = sock.as_sockaddr_in6().unwrap();
210209
return;

0 commit comments

Comments
 (0)