@@ -436,8 +436,8 @@ impl BorrowedFd<'_> {
436
436
/// The resource pointed to by `raw` must remain open for the duration of
437
437
/// the returned `BorrowedFd`, and it must not have the value `-1`.
438
438
#[ inline]
439
- pub unsafe fn borrow_raw ( fd : RawFd ) -> Self {
440
- debug_assert_ne ! ( fd, -1_i32 as RawFd ) ;
439
+ pub const unsafe fn borrow_raw ( fd : RawFd ) -> Self {
440
+ debug_assert ! ( fd != -1_i32 as RawFd ) ;
441
441
Self {
442
442
fd,
443
443
_phantom : PhantomData ,
@@ -451,11 +451,18 @@ impl BorrowedHandle<'_> {
451
451
///
452
452
/// # Safety
453
453
///
454
- /// The resource pointed to by `raw` must remain open for the duration of
455
- /// the returned `BorrowedHandle`, and it must not be null.
454
+ /// The resource pointed to by `handle` must be a valid open handle, it
455
+ /// must remain open for the duration of the returned `BorrowedHandle`.
456
+ ///
457
+ /// Note that it *may* have the value `INVALID_HANDLE_VALUE` (-1), which is
458
+ /// sometimes a valid handle value. See [here] for the full story.
459
+ ///
460
+ /// And, it *may* have the value `NULL` (0), which can occur when consoles are
461
+ /// detached from processes, or when `windows_subsystem` is used.
462
+ ///
463
+ /// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
456
464
#[ inline]
457
- pub unsafe fn borrow_raw ( handle : RawHandle ) -> Self {
458
- debug_assert ! ( !handle. is_null( ) ) ;
465
+ pub const unsafe fn borrow_raw ( handle : RawHandle ) -> Self {
459
466
Self {
460
467
handle,
461
468
_phantom : PhantomData ,
@@ -473,8 +480,8 @@ impl BorrowedSocket<'_> {
473
480
/// the returned `BorrowedSocket`, and it must not have the value
474
481
/// [`INVALID_SOCKET`].
475
482
#[ inline]
476
- pub unsafe fn borrow_raw ( socket : RawSocket ) -> Self {
477
- debug_assert_ne ! ( socket, INVALID_SOCKET as RawSocket ) ;
483
+ pub const unsafe fn borrow_raw ( socket : RawSocket ) -> Self {
484
+ debug_assert ! ( socket != INVALID_SOCKET as RawSocket ) ;
478
485
Self {
479
486
socket,
480
487
_phantom : PhantomData ,
0 commit comments