You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't recall the reasoning for keeping RawWindowHandle around, is there ever a case where it's useful? And wouldn't WindowHandle<'static> be able to serve that same purpose?
I propose we change our API to merge these, so that it's instead something like:
This means that instead of a three-step process for making safe handles (create raw platform handle + wrap in RawWindowHandle + call WindowHandle::borrow_raw), it's now only two steps (create raw platform handle with lifetime + wrap it in WindowHandle).
One reason to not do this would be to mirror the std::os::fd API (RawFd vs BorrowedFd<'_>), but we already can't do that, because we can't provide a mirror of OwnedFd.
I guess another downside is that we'd no longer be able to make fields public (at least not before RFC 3458 is stable and in our MSRV), because then users might assign a NonNull::dangling() into one of the fields.
This has the downside that fields have to be public, because enums have no visibility rules. But if our fields are public anyhow, we might as well IMO.
I'm fine with getting rid of raw window handles entirely, assuming we can't come up with a better use case. As an added bonus, it lets us have more granular safety rules for each window handle. For example, we can make it safe to construct an XCB window handle, but not a Win32 window handle.
One argument for raw handles is it lets us have a raw pointer equivalent for window handles.
It's good to have a RawWindowHandle that represents plain old data, compared to a BorrowedWindowHandle<'static> that represents a valid live window handle.
We should move forwards with getting rid of the subtypes.
Activity
madsmtm commentedon Feb 6, 2026
I guess another downside is that we'd no longer be able to make fields public (at least not before RFC 3458 is stable and in our MSRV), because then users might assign a
NonNull::dangling()into one of the fields.madsmtm commentedon Feb 6, 2026
Another option to simplify things would perhaps be to get rid of the platform-specific wrappers? Something like:
This has the downside that fields have to be public, because enums have no visibility rules. But if our fields are public anyhow, we might as well IMO.
notgull commentedon Feb 6, 2026
I'm fine with getting rid of raw window handles entirely, assuming we can't come up with a better use case. As an added bonus, it lets us have more granular safety rules for each window handle. For example, we can make it safe to construct an XCB window handle, but not a Win32 window handle.
One argument for raw handles is it lets us have a raw pointer equivalent for window handles.
notgull commentedon Mar 14, 2026
Two points from today's meeting:
RawWindowHandlethat represents plain old data, compared to aBorrowedWindowHandle<'static>that represents a valid live window handle.