@@ -70,8 +70,9 @@ pub struct BorrowedFd<'fd> {
70
70
/// so it can be used in FFI in places where a handle is passed as an argument,
71
71
/// it is not captured or consumed, and it is never null.
72
72
///
73
- /// Note that it *may* have the value [`INVALID_HANDLE_VALUE`]. See [here] for
74
- /// the full story.
73
+ /// Note that it *may* have the value `-1`, which in `BorrowedHandle` always
74
+ /// represents the current process handle, and not `INVALID_HANDLE_VALUE`,
75
+ /// despite the two having the same value. See [here] for the full story.
75
76
///
76
77
/// This type's `.to_owned()` implementation returns another `BorrowedHandle`
77
78
/// rather than an `OwnedHandle`. It just makes a trivial copy of the raw
@@ -187,8 +188,9 @@ impl OwnedFd {
187
188
///
188
189
/// This closes the handle on drop.
189
190
///
190
- /// Note that it *may* have the value `INVALID_HANDLE_VALUE` (-1), which is
191
- /// sometimes a valid handle value. See [here] for the full story.
191
+ /// Note that it *may* have the value `-1`, which in `OwnedHandle` always
192
+ /// represents the current process handle, and not `INVALID_HANDLE_VALUE`,
193
+ /// despite the two having the same value. See [here] for the full story.
192
194
///
193
195
/// And, it *may* have the value `NULL` (0), which can occur when consoles are
194
196
/// detached from processes, or when `windows_subsystem` is used.
@@ -375,11 +377,10 @@ impl OwnedSocket {
375
377
/// `INVALID_HANDLE_VALUE`. This ensures that such FFI calls cannot start using the handle without
376
378
/// checking for `INVALID_HANDLE_VALUE` first.
377
379
///
378
- /// This type concerns any value other than `INVALID_HANDLE_VALUE` to be valid, including `NULL`.
379
- /// This is because APIs that use `INVALID_HANDLE_VALUE` as their sentry value may return `NULL`
380
- /// under `windows_subsystem = "windows"` or other situations where I/O devices are detached.
380
+ /// This type may hold any handle value that [`OwnedHandle`] may hold, except that when it holds
381
+ /// `-1`, that value is interpreted to mean `INVALID_HANDLE_VALUE`.
381
382
///
382
- /// If this holds a valid handle, it will close the handle on drop.
383
+ /// If holds a handle other than `INVALID_HANDLE_VALUE` , it will close the handle on drop.
383
384
#[ cfg( windows) ]
384
385
#[ repr( transparent) ]
385
386
#[ derive( Debug ) ]
@@ -395,11 +396,11 @@ pub struct HandleOrInvalid(RawHandle);
395
396
/// `NULL`. This ensures that such FFI calls cannot start using the handle without
396
397
/// checking for `NULL` first.
397
398
///
398
- /// This type concerns any value other than `NULL` to be valid, including `INVALID_HANDLE_VALUE`.
399
- /// This is because APIs that use `NULL` as their sentry value don't treat `INVALID_HANDLE_VALUE`
400
- /// as special .
399
+ /// This type may hold any handle value that [`OwnedHandle`] may hold. As with `OwnedHandle`, when
400
+ /// it holds `-1`, that value is interpreted as the current process handle, and not
401
+ /// `INVALID_HANDLE_VALUE` .
401
402
///
402
- /// If this holds a valid handle, it will close the handle on drop.
403
+ /// If this holds a non-null handle, it will close the handle on drop.
403
404
#[ cfg( windows) ]
404
405
#[ repr( transparent) ]
405
406
#[ derive( Debug ) ]
0 commit comments