Repository: tokio-rs/tokio
File: tokio/src/runtime/mod.rs (Rust)

Code before:
    ///
    /// The Tokio runtime implements `Sync` and `Send` to allow you to wrap it
    /// in a `Arc`. Most fn take `&self` to allow you to call them concurrently
    /// across multiple threads.
    ///
    /// Calls to `shutdown` and `shutdown_timeout` require exclusive ownership of
    /// the runtime type and this can be achieved via `Arc::try_unwrap` when only
    /// one strong count reference is left over.
    ///
    /// [timer]: crate::time
    /// [mod]: index.html
    /// [`new`]: method@Self::new
    /// [`Builder`]: struct@Builder
    #[derive(Debug)]
    pub struct Runtime {
        /// Task scheduler
        scheduler: Scheduler,

        /// Handle to runtime, also contains driver handles
        handle: Handle,

        /// Blocking pool handle, used to signal shutdown
        blocking_pool: BlockingPool,
    }

    /// The flavor of the `Runtime`; the return type for [`Handle::runtime_flavor`](crate::runtime::Handle::runtime_flavor()).
    #[derive(Debug, PartialEq, Eq)]
    #[non_exhaustive]
    pub enum RuntimeFlavor {
        /// The flavor that executes all tasks on the current thread.
        CurrentThread,
        /// The flavor that executes tasks across multiple threads.
        MultiThread,
    }

    /// The runtime scheduler is either a multi-thread or a current-thread executor.
    #[derive(Debug)]
    enum Scheduler {
        /// Execute all tasks on the current-thread.
        CurrentThread(CurrentThread),

        /// Execute tasks across multiple threads.
        #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
        MultiThread(MultiThread),
    }

    /// After thread starts / before thread stops
    type Callback = std::sync::Arc<dyn Fn() + Send + Sync>;

    impl Runtime {
        cfg_not_wasi! {

Review comment (refactor):
Stylistic Choice: The `The flavor of the Runtime` text should be on its own line, since that's the line that appears when you preview this item in docs.rs. The part after the semicolon should be on the line after the initial line, in order to prevent the preview from being too long.

Code after:
    ///
    /// The Tokio runtime implements `Sync` and `Send` to allow you to wrap it
    /// in a `Arc`. Most fn take `&self` to allow you to call them concurrently
    /// across multiple threads.
    ///
    /// Calls to `shutdown` and `shutdown_timeout` require exclusive ownership of
    /// the runtime type and this can be achieved via `Arc::try_unwrap` when only
    /// one strong count reference is left over.
    ///
    /// [timer]: crate::time
    /// [mod]: index.html
    /// [`new`]: method@Self::new
    /// [`Builder`]: struct@Builder
    #[derive(Debug)]
    pub struct Runtime {
        /// Task scheduler
        scheduler: Scheduler,

        /// Handle to runtime, also contains driver handles
        handle: Handle,

        /// Blocking pool handle, used to signal shutdown
        blocking_pool: BlockingPool,
    }

    /// The flavor of a `Runtime`.
    ///
    /// This is the return type for [`Handle::runtime_flavor`](crate::runtime::Handle::runtime_flavor()).
    #[derive(Debug, PartialEq, Eq)]
    #[non_exhaustive]
    pub enum RuntimeFlavor {
        /// The flavor that executes all tasks on the current thread.
        CurrentThread,
        /// The flavor that executes tasks across multiple threads.
        MultiThread,
    }

    /// The runtime scheduler is either a multi-thread or a current-thread executor.
    #[derive(Debug)]
    enum Scheduler {
        /// Execute all tasks on the current-thread.
        CurrentThread(CurrentThread),

        /// Execute tasks across multiple threads.
        #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
        MultiThread(MultiThread),
    }

    /// After thread starts / before thread stops
    type Callback = std::sync::Arc<dyn Fn() + Send + Sync>;