Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee
Make language around `ToOwned` for `BorrowedFd` more precise
This commit is contained in:
commit
3aafbd28e5
1 changed files with 10 additions and 3 deletions
|
@ -24,9 +24,14 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
|
||||||
/// passed as an argument, it is not captured or consumed, and it never has the
|
/// passed as an argument, it is not captured or consumed, and it never has the
|
||||||
/// value `-1`.
|
/// value `-1`.
|
||||||
///
|
///
|
||||||
/// This type's `.to_owned()` implementation returns another `BorrowedFd`
|
/// This type does not have a [`ToOwned`][crate::borrow::ToOwned]
|
||||||
/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file
|
/// implementation. Calling `.to_owned()` on a variable of this type will call
|
||||||
/// descriptor, which is then borrowed under the same lifetime.
|
/// it on `&BorrowedFd` and use `Clone::clone()` like `ToOwned` does for all
|
||||||
|
/// types implementing `Clone`. The result will be descriptor borrowed under
|
||||||
|
/// the same lifetime.
|
||||||
|
///
|
||||||
|
/// To obtain an [`OwnedFd`], you can use [`BorrowedFd::try_clone_to_owned`]
|
||||||
|
/// instead, but this is not supported on all platforms.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[rustc_layout_scalar_valid_range_start(0)]
|
#[rustc_layout_scalar_valid_range_start(0)]
|
||||||
|
@ -50,6 +55,8 @@ pub struct BorrowedFd<'fd> {
|
||||||
/// descriptor, so it can be used in FFI in places where a file descriptor is
|
/// descriptor, so it can be used in FFI in places where a file descriptor is
|
||||||
/// passed as a consumed argument or returned as an owned value, and it never
|
/// passed as a consumed argument or returned as an owned value, and it never
|
||||||
/// has the value `-1`.
|
/// has the value `-1`.
|
||||||
|
///
|
||||||
|
/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`].
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[rustc_layout_scalar_valid_range_start(0)]
|
#[rustc_layout_scalar_valid_range_start(0)]
|
||||||
// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a
|
// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue