Skip to content

Commit a743d1c

Browse files
committed
Add documentation about BorrowedFd::to_owned.
This corresponds to rust-lang/rust#93354, which was recently merged.
1 parent 112a2ea commit a743d1c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/types.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const INVALID_SOCKET: usize = !0 as _;
5050
/// descriptor, so it can be used in FFI in places where a file descriptor is
5151
/// passed as an argument, it is not captured or consumed, and it never has the
5252
/// value `-1`.
53+
///
54+
/// This type's `.to_owned()` implementation returns another `BorrowedFd`
55+
/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file
56+
/// descriptor, which is then borrowed under the same lifetime.
5357
#[cfg(any(unix, target_os = "wasi"))]
5458
#[derive(Copy, Clone)]
5559
#[repr(transparent)]
@@ -75,6 +79,10 @@ pub struct BorrowedFd<'fd> {
7579
/// Note that it *may* have the value [`INVALID_HANDLE_VALUE`]. See [here] for
7680
/// the full story.
7781
///
82+
/// This type's `.to_owned()` implementation returns another `BorrowedHandle`
83+
/// rather than an `OwnedHandle`. It just makes a trivial copy of the raw
84+
/// handle, which is then borrowed under the same lifetime.
85+
///
7886
/// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
7987
#[cfg(windows)]
8088
#[derive(Copy, Clone)]
@@ -93,6 +101,10 @@ pub struct BorrowedHandle<'handle> {
93101
/// so it can be used in FFI in places where a socket is passed as an argument,
94102
/// it is not captured or consumed, and it never has the value
95103
/// [`INVALID_SOCKET`].
104+
///
105+
/// This type's `.to_owned()` implementation returns another `BorrowedSocket`
106+
/// rather than an `OwnedSocket`. It just makes a trivial copy of the raw
107+
/// socket, which is then borrowed under the same lifetime.
96108
#[cfg(windows)]
97109
#[derive(Copy, Clone)]
98110
#[repr(transparent)]

0 commit comments

Comments
 (0)