Replace winapi dependency with windows-sys #291
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The winapi and windows-sys crates both provide bindings to Windows APIs, but winapi is a third-party crate and has been unmaintained for 4 years, with its last release over 5 years ago, while windows-sys is an actively-maintained crate from Microsoft.
My main motivation for this change is to deduplicate Windows API bindings in my dependency tree: pelite is the last of my transitive dependencies that depends on winapi instead of windows-sys, and as far as I can tell the Rust ecosystem is generally moving to the latter (or its higher-level sibling, the windows crate), as windows-sys has more than double the all-time downloads (despite being newer than winapi's most recent release). Although winapi still has more direct dependents, windows-sys + windows together have more, so I think it's increasingly likely that others will be be in the same situation as me.
I considered depending on the windows crate instead, but it doesn't really add much value for pelite's usage, and takes longer to build.
I've also replaced a few
ascasts withptr::cast()calls as the latter is slightly less dangerous, and I've adjusted a piece of pointer arithmetic to preserve provenance.