KEMBAR78
Introducing the dedicated `windows-collections` crate by kennykerr · Pull Request #3483 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@kennykerr
Copy link
Collaborator

The windows crate mostly includes bindings generated by the windows-bindgen crate, but there are a handful of hand-written stock implementations for things like collections, numerics, and async support that I'm planning to move into dedicated crates to make it easier to depend on these implementations without pulling in a dependency on the large windows crate.

This update introduces the windows-collections crate that contains the definitions for the core collection interfaces as well as stock implementations that you can use to avoid having to implement the collection interfaces yourself. The stock collections were first introduced with #2346, #2350, and #2353. These are now all part of the new windows-collections crate. In future I may also provide additional stock implementations, but this covers the vast majority of usage.

This builds on the reference support introduced with the windows-bindgen overhaul introduced in #3359. A minor tweak was required to make it a little more flexible as this is the first major application of the reference redirection capabilities.

Using the new windows-collections crate is easy. Start by adding the following to your Cargo.toml file (once the crate is published):

[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}");
}

@kennykerr kennykerr merged commit c9177f7 into master Feb 13, 2025
84 checks passed
@kennykerr kennykerr deleted the collections branch February 13, 2025 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant