Mention how you can go from `BorrowedFd` to `OwnedFd` and back · patricklam/verify-rust-std@ed3c6d1

Original file line numberDiff line numberDiff line change

@@ -29,6 +29,9 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};

2929

/// it on `&BorrowedFd` and use `Clone::clone()` like `ToOwned` does for all

3030

/// types implementing `Clone`. The result will be descriptor borrowed under

3131

/// the same lifetime.

32+

///

33+

/// To obtain an [`OwnedFd`], you can use [`BorrowedFd::try_clone_to_owned`]

34+

/// instead, but this is not supported on all platforms.

3235

#[derive(Copy, Clone)]

3336

#[repr(transparent)]

3437

#[rustc_layout_scalar_valid_range_start(0)]

@@ -52,6 +55,8 @@ pub struct BorrowedFd<'fd> {

5255

/// descriptor, so it can be used in FFI in places where a file descriptor is

5356

/// passed as a consumed argument or returned as an owned value, and it never

5457

/// has the value `-1`.

58+

///

59+

/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`].

5560

#[repr(transparent)]

5661

#[rustc_layout_scalar_valid_range_start(0)]

5762

// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a