@@ -24,9 +24,14 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
|
24 | 24 | /// passed as an argument, it is not captured or consumed, and it never has the |
25 | 25 | /// value `-1`. |
26 | 26 | /// |
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. |
30 | 35 | #[derive(Copy, Clone)] |
31 | 36 | #[repr(transparent)] |
32 | 37 | #[rustc_layout_scalar_valid_range_start(0)] |
@@ -50,6 +55,8 @@ pub struct BorrowedFd<'fd> {
|
50 | 55 | /// descriptor, so it can be used in FFI in places where a file descriptor is |
51 | 56 | /// passed as a consumed argument or returned as an owned value, and it never |
52 | 57 | /// has the value `-1`. |
| 58 | +/// |
| 59 | +/// You can use [`AsFd::as_fd`] to obtain a [`BorrowedFd`]. |
53 | 60 | #[repr(transparent)] |
54 | 61 | #[rustc_layout_scalar_valid_range_start(0)] |
55 | 62 | // libstd/os/raw/mod.rs assures me that every libstd-supported platform has a |
|