Skip to content

Commit 5d79870

Browse files
committed
Document the valid values for HandleOrNull and HandleOrInvalid.
1 parent e102c2a commit 5d79870

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/os/windows/io/handle.rs

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ pub struct OwnedHandle {
6868
/// `NULL`. This ensures that such FFI calls cannot start using the handle without
6969
/// checking for `NULL` first.
7070
///
71+
/// This type concerns any value other than `NULL` to be valid, including `INVALID_HANDLE_VALUE`.
72+
/// This is because APIs that use `NULL` as their sentry value don't treat `INVALID_HANDLE_VALUE`
73+
/// as special.
74+
///
7175
/// If this holds a valid handle, it will close the handle on drop.
7276
#[repr(transparent)]
7377
#[unstable(feature = "io_safety", issue = "87074")]
@@ -84,6 +88,10 @@ pub struct HandleOrNull(OwnedHandle);
8488
/// `INVALID_HANDLE_VALUE`. This ensures that such FFI calls cannot start using the handle without
8589
/// checking for `INVALID_HANDLE_VALUE` first.
8690
///
91+
/// This type concerns any value other than `INVALID_HANDLE_VALUE` to be valid, including `NULL`.
92+
/// This is because APIs that use `INVALID_HANDLE_VALUE` as their sentry value may return `NULL`
93+
/// under `windows_subsystem = "windows"` or other situations where I/O devices are detached.
94+
///
8795
/// If this holds a valid handle, it will close the handle on drop.
8896
#[repr(transparent)]
8997
#[unstable(feature = "io_safety", issue = "87074")]

0 commit comments

Comments
 (0)