use std::{fmt::Display, future::Future};
use crate::fmt;
pub async fn run<Fun, Fut, Ok, Err>(msg: impl Display, f: Fun) -> Result<Ok, Err>
where
Fun: Fn() -> Fut,
Fut: Future<Output = Result<Ok, Err>>,
{
eprintln!("{}", fmt::plain_headline(msg));
f().await
}
pub async fn run_mut<Fun, Fut, Ok, Err>(msg: impl Display, mut f: Fun) -> Result<Ok, Err>
where
Fun: FnMut() -> Fut,
Fut: Future<Output = Result<Ok, Err>>,
{
eprintln!("{}", fmt::plain_headline(msg));
f().await
}
pub async fn run_once<Fun, Fut, Ok, Err>(msg: impl Display, f: Fun) -> Result<Ok, Err>
where
Fun: FnOnce() -> Fut,
Fut: Future<Output = Result<Ok, Err>>,
{
eprintln!("{}", fmt::plain_headline(msg));
f().await
}