Skip to content

Commit b51ce33

Browse files
committed
[minor] Simpler constructs
1 parent e389f3c commit b51ce33

File tree

1 file changed

+5
-12
lines changed
  • heim-net/src/sys/windows

1 file changed

+5
-12
lines changed

heim-net/src/sys/windows/nic.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,8 @@ pub async fn nic() -> Result<impl Stream<Item = Result<Nic>> + Send + Sync> {
192192
// Step 3 - walk through the list and populate our interfaces
193193
let mut p_next_iface = buffer.as_ptr() as PIP_ADAPTER_ADDRESSES;
194194

195-
let mut cur_iface;
196-
loop {
197-
if p_next_iface.is_null() {
198-
break;
199-
}
200-
cur_iface = unsafe { *p_next_iface };
195+
while !p_next_iface.is_null() {
196+
let cur_iface = unsafe { *p_next_iface };
201197

202198
let iface_index = unsafe { cur_iface.u.s().IfIndex };
203199
let iface_guid_cstr;
@@ -229,12 +225,9 @@ pub async fn nic() -> Result<impl Stream<Item = Result<Nic>> + Send + Sync> {
229225

230226
// Walk through every IP address of this interface
231227
let mut p_next_address = cur_iface.FirstUnicastAddress;
232-
let mut cur_address;
233-
loop {
234-
if p_next_address.is_null() {
235-
break;
236-
}
237-
cur_address = unsafe { *p_next_address };
228+
229+
while !p_next_address.is_null() {
230+
let cur_address = unsafe { *p_next_address };
238231

239232
let this_socket_address = cur_address.Address;
240233
let this_netmask_length = cur_address.OnLinkPrefixLength;

0 commit comments

Comments
 (0)