[go: up one dir, main page]

Crate windows_collections

Source
Expand description

§Windows collection types

The windows-collections crate provides stock collection support for Windows APIs.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-collections]
version = "0.1"

Use the Windows collection types as needed:

use windows_collections::*;

let numbers = IIterable::<i32>::from(vec![1, 2, 3]);

for value in numbers {
    println!("{value}");
}

Naturally, the Windows collection types work with other Windows crates:

use windows_collections::*;
use windows_result::*;
use windows_strings::*;

fn main() -> Result<()> {
    let greetings =
        IVectorView::<HSTRING>::from(vec![HSTRING::from("hello"), HSTRING::from("world")]);

    for value in greetings {
        println!("{value}");
    }

    let map = std::collections::BTreeMap::from([("one".into(), 1), ("two".into(), 2)]);
    let map = IMapView::<HSTRING, i32>::from(map);

    assert_eq!(map.Lookup(h!("one"))?, 1);
    assert_eq!(map.Lookup(h!("two"))?, 2);

    Ok(())
}

Structs§

IIterable
IIterable_Vtbl
IIterator
IIterator_Vtbl
IKeyValuePair
IKeyValuePair_Vtbl
IMap
IMapView
IMapView_Vtbl
IMap_Vtbl
IVector
IVectorView
IVectorView_Vtbl
IVector_Vtbl

Traits§

IIterable_Impl
IIterator_Impl
IKeyValuePair_Impl
IMapView_Impl
IMap_Impl
IVectorView_Impl
IVector_Impl