This was added in Rust 1.63 and avoids the drop issue with .as_raw_fd() as well as making the lifetime rules of file descriptors clearer. The stdlib API is designed such that we should be able to use BorrowedFd and OwnedFd as file descriptor arguments and return values in C FFI as well.
This would also let clean up RawFdExt::try_clone_hotfix for RawFd by using BorrowedFd::try_clone_to_owned (and File::try_clone is fixed since Rust 1.37).
This was added in Rust 1.63 and avoids the drop issue with
.as_raw_fd()
as well as making the lifetime rules of file descriptors clearer. The stdlib API is designed such that we should be able to useBorrowedFd
andOwnedFd
as file descriptor arguments and return values in C FFI as well.