From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustix/tests/io/from_into.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 vendor/rustix/tests/io/from_into.rs (limited to 'vendor/rustix/tests/io/from_into.rs') diff --git a/vendor/rustix/tests/io/from_into.rs b/vendor/rustix/tests/io/from_into.rs new file mode 100644 index 000000000..94d915993 --- /dev/null +++ b/vendor/rustix/tests/io/from_into.rs @@ -0,0 +1,28 @@ +#[cfg(feature = "fs")] +#[cfg(not(target_os = "redox"))] +#[test] +fn test_owned() { + use rustix::fd::AsFd; + #[cfg(unix)] + use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd}; + #[cfg(target_os = "wasi")] + use std::os::wasi::io::{AsRawFd, FromRawFd, IntoRawFd}; + + let file = rustix::fs::openat( + rustix::fs::cwd(), + "Cargo.toml", + rustix::fs::OFlags::RDONLY, + rustix::fs::Mode::empty(), + ) + .unwrap(); + + let raw = file.as_raw_fd(); + assert_eq!(raw, file.as_fd().as_raw_fd()); + + let inner = file.into_raw_fd(); + assert_eq!(raw, inner); + + let new = unsafe { rustix::io::OwnedFd::from_raw_fd(inner) }; + let mut buf = [0_u8; 4]; + let _ = rustix::io::read(&new, &mut buf).unwrap(); +} -- cgit v1.2.3