windows_ext/
lib.rs

1#![deny(missing_docs, rustdoc::broken_intra_doc_links, clippy::cargo)]
2
3//! # Extensions for `windows-rs`
4//! The extensions defined in this module aim to help make the windows crates more ergonomic to use, providing the
5//! well-known macros from the SDK headers to us mere mortals who prefer memory safety and fearlessness.
6//!
7//! By default, the minwindef functions are included as these are frequently imported either directly or indirectly
8//! (a lot of the other headers import it too) and a quick search for the name reveals it's at least _referenced_ in
9//! 58 other headers. An additional feature will become available that makes the functions defined there also available
10//! through implemented traits for some of the types defined in the windows crates.
11//!
12//! Exporting the minwindef functions, however useful they may be, can be turned off by using the `no-minwindef`
13//! anti-feature. This only disables its export, not its use elsewhere in this crate. The functions are a bunch of
14//! oneliners annotated for always inlinging. This was done both to keep in line with what C++ does with macros
15//! (expanding the code inline at compile time) and because the function call would be inlined with any level of
16//! optimization enabled (yes, even `-O1`). Sorry, but there is no plan to manually inline code being called in as many
17//! places as this based on a feature flag when the output would be no different either way. The inline annotation was
18//! added instead, as a way to not impact the resulting binary size; the function call is almost as big as the bitops.
19//!
20//! As it stands, this crate only implements a single header. Please do feel free to contribute to the project by
21//! implementing more macros and header-only functions that aren't available in the windows-rs bindings!
22
23#[cfg(feature = "minwindef")]
24pub mod minwindef;
25#[cfg(not(feature = "minwindef"))]
26pub(crate) mod minwindef;
27
28/// Wrapper for all extension traits this crate defines
29///
30/// All traits can be used with `use windows_ext::ext::*`.
31#[cfg(feature = "ext-impls")]
32pub mod ext {
33    #[cfg(feature = "minwindef")]
34    pub use crate::minwindef::ext::*;
35}