openSUSE / libpathrs

C-friendly API to make path resolution safer on Linux.
GNU Lesser General Public License v3.0
83 stars 6 forks source link

all: switch to os::fd::{Owned,Borrowed}Fd API? #40

Closed cyphar closed 3 months ago

cyphar commented 4 months ago

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.

cyphar commented 4 months ago

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