dtolnay/anyhow

make ensure!() return Ok(())

aruediger opened this issue · 1 comments

ensure!() currently evaluates to () on success so one has to write

fn check() -> anyhow::Result<()> {
  ensure!(true);
  Ok(())
}

or

fn check() -> anyhow::Result<()> {
  Ok(ensure!(true))
}

If ensure would provide an else branch that returns Ok(()) then this would work:

fn check() -> anyhow::Result<()> {
  ensure!(true)
}

This might break backwards compatibiity, though.

I think this is better with the current signature.