Skip to content

Commit 20ae4da

Browse files
committed
Update the documentation for {As,Into,From}Raw{Fd,Handle,Socket}
This ports the changes proposed in rust-lang/rust#93562 to io-lifetimes. Specifically, remove the redundant comments on `OwnedHandle::from_raw_handle` and `OwnedSocket::from_raw_socket`, and remove the `FromRawHandle` impls for `HandleOrInvalid` and `HandleOrNull`.
1 parent ffc0e79 commit 20ae4da

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/types.rs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,6 @@ impl FromRawFd for OwnedFd {
399399

400400
#[cfg(windows)]
401401
impl FromRawHandle for OwnedHandle {
402-
/// Constructs a new instance of `Self` from the given raw handle.
403-
///
404-
/// # Safety
405-
///
406-
/// The resource pointed to by `raw` must be open and suitable for assuming
407-
/// ownership.
408402
#[inline]
409403
unsafe fn from_raw_handle(handle: RawHandle) -> Self {
410404
Self { handle }
@@ -413,12 +407,6 @@ impl FromRawHandle for OwnedHandle {
413407

414408
#[cfg(windows)]
415409
impl FromRawSocket for OwnedSocket {
416-
/// Constructs a new instance of `Self` from the given raw socket.
417-
///
418-
/// # Safety
419-
///
420-
/// The resource pointed to by `raw` must be open and suitable for assuming
421-
/// ownership.
422410
#[inline]
423411
unsafe fn from_raw_socket(socket: RawSocket) -> Self {
424412
debug_assert_ne!(socket, INVALID_SOCKET as RawSocket);
@@ -427,7 +415,7 @@ impl FromRawSocket for OwnedSocket {
427415
}
428416

429417
#[cfg(windows)]
430-
impl FromRawHandle for HandleOrInvalid {
418+
impl HandleOrInvalid {
431419
/// Constructs a new instance of `Self` from the given `RawHandle` returned
432420
/// from a Windows API that uses `INVALID_HANDLE_VALUE` to indicate
433421
/// failure, such as `CreateFileW`.
@@ -437,20 +425,20 @@ impl FromRawHandle for HandleOrInvalid {
437425
///
438426
/// # Safety
439427
///
440-
/// The resource pointed to by `handle` must be either open and otherwise
441-
/// unowned, null, or equal to `INVALID_HANDLE_VALUE` (-1). Note that not
442-
/// all Windows APIs use `INVALID_HANDLE_VALUE` for errors; see [here] for
443-
/// the full story.
428+
/// The passed `handle` value must either satisfy the safety requirements
429+
/// of [`FromRawHandle::from_raw_handle`], or be
430+
/// `INVALID_HANDLE_VALUE` (-1). Note that not all Windows APIs use
431+
/// `INVALID_HANDLE_VALUE` for errors; see [here] for the full story.
444432
///
445433
/// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
446434
#[inline]
447-
unsafe fn from_raw_handle(handle: RawHandle) -> Self {
435+
pub unsafe fn from_raw_handle(handle: RawHandle) -> Self {
448436
Self(handle)
449437
}
450438
}
451439

452440
#[cfg(windows)]
453-
impl FromRawHandle for HandleOrNull {
441+
impl HandleOrNull {
454442
/// Constructs a new instance of `Self` from the given `RawHandle` returned
455443
/// from a Windows API that uses null to indicate failure, such as
456444
/// `CreateThread`.
@@ -460,13 +448,13 @@ impl FromRawHandle for HandleOrNull {
460448
///
461449
/// # Safety
462450
///
463-
/// The resource pointed to by `handle` must be either open and otherwise
464-
/// unowned, or null. Note that not all Windows APIs use null for errors;
465-
/// see [here] for the full story.
451+
/// The passed `handle` value must either satisfy the safety requirements
452+
/// of [`FromRawHandle::from_raw_handle`], or be null. Note that not all
453+
/// Windows APIs use null for errors; see [here] for the full story.
466454
///
467455
/// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
468456
#[inline]
469-
unsafe fn from_raw_handle(handle: RawHandle) -> Self {
457+
pub unsafe fn from_raw_handle(handle: RawHandle) -> Self {
470458
Self(handle)
471459
}
472460
}

0 commit comments

Comments
 (0)