The following code will never terminate (until it runs out of memory):
fn main() {
if let Ok(key) = winreg::RegKey::predef(HKEY_CURRENT_USER)
.open_subkey_with_flags(r"SOFTWARE\Classes\tel", winreg::enums::KEY_SET_VALUE)
{
let _: Vec<_> = key.enum_values().collect();
}
}
While the problem is obvious (you need to include winreg::enums::KEY_READ), the failure case is confusing. It might be more intuitive if enum_values (and presumably enum_keys) returned a single Err for the ERROR_ACCESS_DENIED, returned an empty iterator, or had a return value of io::Result<EnumValues> instead. :)
The following code will never terminate (until it runs out of memory):
While the problem is obvious (you need to include
winreg::enums::KEY_READ
), the failure case is confusing. It might be more intuitive ifenum_values
(and presumablyenum_keys
) returned a singleErr
for theERROR_ACCESS_DENIED
, returned an empty iterator, or had a return value ofio::Result<EnumValues>
instead. :)