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

Code before:
use std::io;
use std::path::Path;

use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};

use crate::net::{UnixDatagram, UnixListener, UnixStream};

cfg_net_unix! {
    /// A Unix socket that has not yet been converted to a `UnixStream`, `UnixDatagram`, or
    /// `UnixListener`.
    ///
    /// `UnixSocket` wraps an operating system socket and enables the caller to
    /// configure the socket before establishing a connection or accepting
    /// inbound connections. The caller is able to set socket option and explicitly
    /// bind the socket with a socket address.
    ///
    /// The underlying socket is closed when the `UnixSocket` value is dropped.
    ///
    /// `UnixSocket` should only be used directly if the default configuration used
    /// by `UnixStream::connect`, `UnixDatagram::bind`, and `UnixListener::bind`
    /// does not meet the required use case.
    ///
    /// Calling `UnixStream::connect(path)` is equivalent to:
    ///
    /// ```no_run
    /// use tokio::net::UnixSocket;
    /// use std::error::Error;
    ///
    /// #[tokio::main]
    /// async fn main() -> Result<(), Box<dyn Error>> {
    ///     let dir = tempfile::tempdir().unwrap();
    ///     let path = dir.path().join("bind_path");
    ///     let socket = UnixSocket::new_stream()?;
    ///
    ///     let stream = socket.connect(path).await?;
    ///
    ///     Ok(())
    /// }
    /// ```
    ///
    /// Calling `UnixDatagram::bind(path)` is equivalent to:
    ///
    /// ```no_run
    /// use tokio::net::UnixSocket;
    /// use std::error::Error;

Review comment (suggestion):
These can be links.
```suggestion
    /// by [`UnixStream::connect`], [`UnixDatagram::bind`], and [`UnixListener::bind`]
```

Code after:
use std::io;
use std::path::Path;

use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};

use crate::net::{UnixDatagram, UnixListener, UnixStream};

cfg_net_unix! {
    /// A Unix socket that has not yet been converted to a [`UnixStream`], [`UnixDatagram`], or
    /// [`UnixListener`].
    ///
    /// `UnixSocket` wraps an operating system socket and enables the caller to
    /// configure the socket before establishing a connection or accepting
    /// inbound connections. The caller is able to set socket option and explicitly
    /// bind the socket with a socket address.
    ///
    /// The underlying socket is closed when the `UnixSocket` value is dropped.
    ///
    /// `UnixSocket` should only be used directly if the default configuration used
    /// by [`UnixStream::connect`], [`UnixDatagram::bind`], and [`UnixListener::bind`]
    /// does not meet the required use case.
    ///
    /// Calling `UnixStream::connect(path)` effectively performs the same function as:
    ///
    /// ```no_run
    /// use tokio::net::UnixSocket;
    /// use std::error::Error;
    ///
    /// #[tokio::main]
    /// async fn main() -> Result<(), Box<dyn Error>> {
    ///     let dir = tempfile::tempdir().unwrap();
    ///     let path = dir.path().join("bind_path");
    ///     let socket = UnixSocket::new_stream()?;
    ///
    ///     let stream = socket.connect(path).await?;
    ///
    ///     Ok(())
    /// }
    /// ```
    ///
    /// Calling `UnixDatagram::bind(path)` effectively performs the same function as:
    ///
    /// ```no_run
    /// use tokio::net::UnixSocket;
    /// use std::error::Error;