Skip to content
Myr

Call out that `bail!` and `ensure!` require anyhow::Error in the return type

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 75f57ed · Browse files · 1 file+6 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−0 removed

  • other:+6 added−0 removed

1 file+6 added−0 removed

modified:src/macros.rs+6 added
1/// Return early with an error.2///3/// This macro is equivalent to `return Err(anyhow!($args...))`.4///5/// The surrounding function's or closure's return value is required to be6/// `Result<_, anyhow::Error>`.7///8/// # Example9///10/// ```11/// # use anyhow::{bail, Result};
54 unmodified lines
66/// Return early with an error if a condition is not satisfied.67///68/// This macro is equivalent to `if !$cond { return Err(anyhow!($args...)); }`.69///70/// The surrounding function's or closure's return value is required to be71/// `Result<_, anyhow::Error>`.72///73/// Analogously to `assert!`, `ensure!` takes a condition and exits the function74/// if the condition fails. Unlike `assert!`, `ensure!` returns an `Error`75/// rather than panicking.76///
99 unmodified lines