-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: IMapView.Lookup fails with 0x0 when key DOES exist #2604
Comments
I'm not familiar with this API but looking at Properties it returns an |
Here's an example of how this works:
use std::collections::*;
use windows::{core::*, Foundation::Collections::*, Foundation::*};
fn main() -> Result<()> {
let object: IInspectable = 123.try_into()?;
let mut map = BTreeMap::new();
map.insert(h!("some").clone(), Some(object));
map.insert(h!("none").clone(), None);
let map: IMapView<HSTRING, IInspectable> = map.try_into()?;
let some = map.Lookup(h!("some")).expect("should be Ok");
assert_eq!(123, some.cast::<IReference<i32>>()?.Value()?);
let none = map.Lookup(h!("none")).expect_err("should be Err");
assert_eq!(Error::OK, none);
assert_eq!(HRESULT(0), none.code());
Ok(())
} |
Beyond that, I'd recommend the following resources for API questions: Also, once I have completed #332 it should be a lot simpler to wire up the event handlers. 😊 |
@kennykerr thanks for the clarification. |
Yes, the trouble is knowing which are likely to be nullable vs not. At this point, all are theoretically nullable but then you end up having to unwrap both the |
Which crate is this about?
windows
Crate version
0.48.0
Summary
Hi there, firstly, thanks for the effort on creating these bindings, they are really helpful to write safe programs!
I noticed that IMapView Lookup's method, will always fail when it does contain a key, but that only happens on IMapView returned from
DeviceWatcher
and it does not happen if you useTryFrom
to convert a BTreeMap into IMapView and then Lookup the key.Toolchain version/configuration
Default host x86_64-pc-windows-msvc
rustup home: USER.rustup
stable-x86_64-pc-windows-msvc (default)
rustc 1.70.0 (90c541806 2023-05-31)
Reproducible example
Crate manifest
Expected behavior
Lookup should return Ok(I-something)
Actual behavior
This gets printed:
Additional comments
No response
The text was updated successfully, but these errors were encountered: