Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee · model-checking/verify-rust-std@cc4ed95

Original file line numberDiff line numberDiff line change

@@ -24,9 +24,14 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};

2424

/// passed as an argument, it is not captured or consumed, and it never has the

2525

/// value `-1`.

2626

///

27-

/// This type's `.to_owned()` implementation returns another `BorrowedFd`

28-

/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file

29-

/// descriptor, which is then borrowed under the same lifetime.

27+

/// This type does not have a [`ToOwned`][crate::borrow::ToOwned]

28+

/// implementation. Calling `.to_owned()` on a variable of this type will call

29+

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

30+

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

31+

/// 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.

3035

#[derive(Copy, Clone)]

3136

#[repr(transparent)]

3237

#[rustc_layout_scalar_valid_range_start(0)]

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

5055

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

5156

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

5257

/// has the value `-1`.

58+

///

59+

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

5360

#[repr(transparent)]

5461

#[rustc_layout_scalar_valid_range_start(0)]

5562

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