<p><span class="h-card"><a href="https://mastodon.social/@gamingonlinux" class="u-url mention">@<span>gamingonlinux</span></a></span></p><p>Hmm.</p><p>It looks like Microsoft wanted DEV_BROADCAST_HDR to be a discriminated union, but with the different variants having different sizes, presumably so that they could introduce new variants later without breaking existing code.</p><p>This is the correct way to accomplish that.</p><p><a href="https://mastodon.sdf.org/tags/Rust" class="mention hashtag" rel="tag">#<span>Rust</span></a> does something similar for trait object downcasting: check if the desired type is the same as the actual type, and if so, cast the pointer.</p><p>Check: <a href="https://doc.rust-lang.org/1.85.0/src/core/any.rs.html#225" target="_blank" rel="nofollow noopener noreferrer"><span class="invisible">https://</span><span class="ellipsis">doc.rust-lang.org/1.85.0/src/c</span><span class="invisible">ore/any.rs.html#225</span></a><br />Cast: <a href="https://doc.rust-lang.org/1.85.0/src/core/any.rs.html#294" target="_blank" rel="nofollow noopener noreferrer"><span class="invisible">https://</span><span class="ellipsis">doc.rust-lang.org/1.85.0/src/c</span><span class="invisible">ore/any.rs.html#294</span></a></p>