@@ -40,6 +40,7 @@ pub trait AsRawFd {
40
40
///
41
41
/// let mut f = File::open("foo.txt")?;
42
42
/// // Note that `raw_fd` is only valid as long as `f` exists.
43
+ /// #[cfg(any(unix, target_os = "wasi"))]
43
44
/// let raw_fd: RawFd = f.as_raw_fd();
44
45
/// # Ok::<(), io::Error>(())
45
46
/// ```
@@ -75,9 +76,11 @@ pub trait FromRawFd {
75
76
/// use std::os::wasi::io::{FromRawFd, IntoRawFd, RawFd};
76
77
///
77
78
/// let f = File::open("foo.txt")?;
79
+ /// # #[cfg(any(unix, target_os = "wasi"))]
78
80
/// let raw_fd: RawFd = f.into_raw_fd();
79
81
/// // SAFETY: no other functions should call `from_raw_fd`, so there
80
82
/// // is only one owner for the file descriptor.
83
+ /// # #[cfg(any(unix, target_os = "wasi"))]
81
84
/// let f = unsafe { File::from_raw_fd(raw_fd) };
82
85
/// # Ok::<(), io::Error>(())
83
86
/// ```
@@ -106,6 +109,7 @@ pub trait IntoRawFd {
106
109
/// use std::os::wasi::io::{IntoRawFd, RawFd};
107
110
///
108
111
/// let f = File::open("foo.txt")?;
112
+ /// #[cfg(any(unix, target_os = "wasi"))]
109
113
/// let raw_fd: RawFd = f.into_raw_fd();
110
114
/// # Ok::<(), io::Error>(())
111
115
/// ```
0 commit comments