@@ -40,6 +40,7 @@ pub trait AsRawFd {
4040 ///
4141 /// let mut f = File::open("foo.txt")?;
4242 /// // Note that `raw_fd` is only valid as long as `f` exists.
43+ /// #[cfg(any(unix, target_os = "wasi"))]
4344 /// let raw_fd: RawFd = f.as_raw_fd();
4445 /// # Ok::<(), io::Error>(())
4546 /// ```
@@ -75,9 +76,11 @@ pub trait FromRawFd {
7576 /// use std::os::wasi::io::{FromRawFd, IntoRawFd, RawFd};
7677 ///
7778 /// let f = File::open("foo.txt")?;
79+ /// # #[cfg(any(unix, target_os = "wasi"))]
7880 /// let raw_fd: RawFd = f.into_raw_fd();
7981 /// // SAFETY: no other functions should call `from_raw_fd`, so there
8082 /// // is only one owner for the file descriptor.
83+ /// # #[cfg(any(unix, target_os = "wasi"))]
8184 /// let f = unsafe { File::from_raw_fd(raw_fd) };
8285 /// # Ok::<(), io::Error>(())
8386 /// ```
@@ -106,6 +109,7 @@ pub trait IntoRawFd {
106109 /// use std::os::wasi::io::{IntoRawFd, RawFd};
107110 ///
108111 /// let f = File::open("foo.txt")?;
112+ /// #[cfg(any(unix, target_os = "wasi"))]
109113 /// let raw_fd: RawFd = f.into_raw_fd();
110114 /// # Ok::<(), io::Error>(())
111115 /// ```
0 commit comments