diff --git a/ports/cef/string_map.rs b/ports/cef/string_map.rs index 0d01888601e..2c50d91eb34 100644 --- a/ports/cef/string_map.rs +++ b/ports/cef/string_map.rs @@ -60,17 +60,17 @@ pub extern "C" fn cef_string_map_key(sm: *mut cef_string_map_t, index: c_int, va if index < 0 || sm.is_null() { return 0; } if index as usize > (*sm).len() - 1 { return 0; } - for (i, k) in (*sm).keys().enumerate() { - if i == index as usize { + match (*sm).keys().nth(index as usize) { + Some(k) => { cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16, k.len() as u64, value, 1); - return 1; - } + 1 + }, + None => 0, } } - 0 } #[no_mangle] @@ -79,14 +79,14 @@ pub extern "C" fn cef_string_map_value(sm: *mut cef_string_map_t, index: c_int, if index < 0 || sm.is_null() { return 0; } if index as usize > (*sm).len() - 1 { return 0; } - for (i, val) in (*sm).values().enumerate() { - if i == index as usize { + match (*sm).values().nth(index as usize) { + Some(val) => { cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1); - return 1; - } + 1 + }, + None => 0, } } - 0 } #[no_mangle]