testutils 0.0.12

Offers a range of utility functions, macros, and tools, such as `simple_benchmark()` and `dbg_ref!()`, `os_cmd::Runner`, designed for testing purposes.
Documentation
use crate::os_cmd::MiniStr;

#[derive(Debug, Clone, Default)]
/// cargo sub command: e.g., build, run
pub enum SubCmd {
  #[default]
  Build,
  Run,
  Test,
  Bench,
  Check,
  Rustc,
  Custom(MiniStr),
}

impl From<&str> for SubCmd {
  fn from(value: &str) -> Self {
    use SubCmd::*;
    match value {
      "build" => Build,
      "run" => Run,
      "test" => Test,
      "bench" => Bench,
      "check" => Check,
      "rustc" => Rustc,
      v => Custom(v.into()),
    }
  }
}

impl SubCmd {
  const fn as_static_str(&self) -> &str {
    use SubCmd::*;

    match self {
      Build => "build",
      Run => "run",
      Test => "test",
      Bench => "bench",
      Check => "check",
      Rustc => "rustc",
      _ => "",
    }
  }
  /// Converts SubCmd as `&str`
  pub fn as_str(&self) -> &str {
    match self {
      Self::Custom(s) => s.as_ref(),
      _ => self.as_static_str(),
    }
  }
}
impl AsRef<str> for SubCmd {
  fn as_ref(&self) -> &str {
    self.as_str()
  }
}