Skip to content

Commit 2f75b4a

Browse files
committed
HandleOrNull can hold null, and HandleOrInvalid can hold INVALID_HANDLE_VALUE.
1 parent 0a39e5a commit 2f75b4a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

+5-9
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ pub struct OwnedHandle {
7777
/// `NULL`. This ensures that such FFI calls cannot start using the handle without
7878
/// checking for `NULL` first.
7979
///
80-
/// This type may hold any handle value that [`OwnedHandle`] may hold, except `NULL`. It may
81-
/// hold `-1`, even though `-1` has the same value as `INVALID_HANDLE_VALUE`, because in
82-
/// `HandleOrNull`, `-1` is interpreted to mean the current process handle.
80+
/// This type may hold any handle value that [`OwnedHandle`] may hold. As with `OwnedHandle`, when
81+
/// it holds `-1`, that value is interpreted as the current process handle, and not
82+
/// `INVALID_HANDLE_VALUE`.
8383
///
8484
/// If this holds a non-null handle, it will close the handle on drop.
8585
#[repr(transparent)]
@@ -97,12 +97,8 @@ pub struct HandleOrNull(OwnedHandle);
9797
/// `INVALID_HANDLE_VALUE`. This ensures that such FFI calls cannot start using the handle without
9898
/// checking for `INVALID_HANDLE_VALUE` first.
9999
///
100-
/// This type may hold any handle value that [`OwnedHandle`] may hold, except `-1`. It must not
101-
/// hold `-1`, because `-1` in `HandleOrInvalid` is interpreted to mean `INVALID_HANDLE_VALUE`.
102-
///
103-
/// This type may hold `NULL`, because APIs that use `INVALID_HANDLE_VALUE` as their sentry value
104-
/// may return `NULL` under `windows_subsystem = "windows"` or other situations where I/O devices
105-
/// are detached.
100+
/// This type may hold any handle value that [`OwnedHandle`] may hold, except that when it holds
101+
/// `-1`, that value is interpreted to mean `INVALID_HANDLE_VALUE`.
106102
///
107103
/// If holds a handle other than `INVALID_HANDLE_VALUE`, it will close the handle on drop.
108104
#[repr(transparent)]

0 commit comments

Comments
 (0)