diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-06-28 09:17:39 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-07-17 14:34:00 +0200 |
| commit | 2162f3f34b2b4f9a7d603ab05bec4246a7b855c0 (patch) | |
| tree | 29db2c1230026c7f1b2385efc102c99e99fd4ded /library/std | |
| parent | 538b31e9774e3c6e0561e8dbcef378deba9f3fdc (diff) | |
| download | rust-2162f3f34b2b4f9a7d603ab05bec4246a7b855c0.tar.gz rust-2162f3f34b2b4f9a7d603ab05bec4246a7b855c0.zip | |
Mention how you can go from `BorrowedFd` to `OwnedFd` and back
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/os/fd/owned.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index f11f7ef938a..5833c597256 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -29,6 +29,9 @@ use crate::sys_common::{AsInner, FromInner, IntoInner}; /// 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)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(0)] @@ -52,6 +55,8 @@ pub struct BorrowedFd<'fd> { /// 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 /// has the value `-1`. +/// +/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`]. #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(0)] // libstd/os/raw/mod.rs assures me that every libstd-supported platform has a |
