Why is the compiler expecting a Vecin the line "for name in ..." because of the return type? And how to fix that. Of course I want to fill the Vec inside the for statement.
fn regkeyloop(regpath: &str) -> Vec<Software>{
let mut myvec = Vec::<Software>::new();
let subkey = winreg::RegKey::predef(HKEY_LOCAL_MACHINE)
.open_subkey_with_flags(regpath, KEY_READ)
.unwrap();
for name in subkey.enum_keys().map(|x| x.unwrap()) {
myvec.push(Software {
DisplayName : name.to_string(),
Publisher : "Ms".to_string(),
DisplayVersion : "1".to_string(),
});
return myvec;
}
}
@Cerber-Ursi As someone not familiar with this issue, I can try to run it and look at the compile error, but no from just inspecting the code I see no obvious ) vs } mismatch.
In fact I see only balanced parens and brackets, so why the error occurs at all is still a mystery to me (note that I'm not trying very hard atm).
Then again, I also don't see it in the OP so take this post for what you will