Documentation
#![warn(missing_docs)]
#![warn(clippy::pedantic)]
#![no_std]

//! Because copy pasting the same thing into every new project is annoying

/// [`tokio::select!`](https://docs.rs/tokio/latest/tokio/macro.select.html) but formattable by
/// `rustfmt`
///
/// ```text
/// (
///   biased,
/// )?
/// (
///   <async expression>,
///   ({ <precondition> },)?
///   |<pattern>| <handler>
/// ),*
/// ```
#[macro_export]
macro_rules! select {
  (
    $(
      $fut:expr,
      $({ $if:expr },)?
      |$binding:pat_param| $handler:expr
    ),*
    $(,)?
  ) => {
    ::tokio::select! {
      $(
        $binding = $fut $(, if $if)? => { $handler }
      ),*
    }
  };

  (
    biased,
    $(
      $fut:expr,
      $({ $if:expr },)?
      |$binding:pat_param| $handler:expr
    ),*
    $(,)?
  ) => {
    ::tokio::select! {
      biased;

      $(
        $binding = $fut $(, if $if)? => { $handler }
      ),*
    }
  };
}