Repository: tokio-rs/tokio
File: tokio/src/net/unix/pipe.rs (Rust)

Code before:
    ///     }
    ///
    ///     Ok(())
    /// }
    /// ```
    pub fn try_write_vectored(&self, buf: &[io::IoSlice<'_>]) -> io::Result<usize> {
        self.io
            .registration()
            .try_io(Interest::WRITABLE, || (&*self.io).write_vectored(buf))
    }

    /// Converts the pipe into an [`OwnedFd`] in blocking mode.
    ///
    /// This function will deregister this pipe end from the event loop, set
    /// it in blocking mode and perform the conversion.
    pub fn into_blocking_fd(self) -> io::Result<OwnedFd> {
        let fd = self.into_nonblocking_fd()?;
        set_blocking(&fd)?;
        Ok(fd)
    }

    /// Converts the pipe into an [`OwnedFd`] in nonblocking mode.
    ///
    /// This function will deregister this pipe end from the event loop and
    /// perform the conversion. Returned file descriptor will be in nonblocking
    /// mode.
    pub fn into_nonblocking_fd(self) -> io::Result<OwnedFd> {
        let mio_pipe = self.io.into_inner()?;

        // Safety: the pipe is now deregistered from the event loop
        // and we are the only owner of this pipe end.
        let owned_fd = unsafe { OwnedFd::from_raw_fd(mio_pipe.into_raw_fd()) };

        Ok(owned_fd)
    }
}

impl AsyncWrite for Sender {
    fn poll_write(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<io::Result<usize>> {
        self.io.poll_write(cx, buf)
    }

    fn poll_write_vectored(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        bufs: &[io::IoSlice<'_>],
    ) -> Poll<io::Result<usize>> {

Review comment (suggestion):
```suggestion
    /// perform the conversion. The returned file descriptor will be in nonblocking
    /// mode.
```

Code after:
    ///     }
    ///
    ///     Ok(())
    /// }
    /// ```
    pub fn try_write_vectored(&self, buf: &[io::IoSlice<'_>]) -> io::Result<usize> {
        self.io
            .registration()
            .try_io(Interest::WRITABLE, || (&*self.io).write_vectored(buf))
    }

    /// Converts the pipe into an [`OwnedFd`] in blocking mode.
    ///
    /// This function will deregister this pipe end from the event loop, set
    /// it in blocking mode and perform the conversion.
    pub fn into_blocking_fd(self) -> io::Result<OwnedFd> {
        let fd = self.into_nonblocking_fd()?;
        set_blocking(&fd)?;
        Ok(fd)
    }

    /// Converts the pipe into an [`OwnedFd`] in nonblocking mode.
    ///
    /// This function will deregister this pipe end from the event loop and
    /// perform the conversion. The returned file descriptor will be in nonblocking
    /// mode.
    pub fn into_nonblocking_fd(self) -> io::Result<OwnedFd> {
        let mio_pipe = self.io.into_inner()?;

        // Safety: the pipe is now deregistered from the event loop
        // and we are the only owner of this pipe end.
        let owned_fd = unsafe { OwnedFd::from_raw_fd(mio_pipe.into_raw_fd()) };

        Ok(owned_fd)
    }
}

impl AsyncWrite for Sender {
    fn poll_write(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<io::Result<usize>> {
        self.io.poll_write(cx, buf)
    }

    fn poll_write_vectored(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        bufs: &[io::IoSlice<'_>],
    ) -> Poll<io::Result<usize>> {