diff --git a/book/src/bail-and-ensure.md b/book/src/bail-and-ensure.md index 1326f0e..37411ba 100644 --- a/book/src/bail-and-ensure.md +++ b/book/src/bail-and-ensure.md @@ -1,6 +1,6 @@ # `bail!` and `ensure!` -If you were a fan of the `bail!` and ensure! macros from error-chain, good news. failure has a version of these macros as well. +If you were a fan of the `bail!` and `ensure!` macros from error-chain, good news. failure has a version of these macros as well. The `bail!` macro returns an error immediately, based on a format string. The `ensure!` macro additionally takes a conditional, and returns the error only if that conditional is false. You can think of `bail!` and `ensure!` as being analogous to `panic!` and `assert!`, but throwing errors instead of panicking. @@ -15,4 +15,4 @@ fn safe_cast_to_unsigned(n:i32) -> Result ensure!(n>=0, "number cannot be smaller than 0!"); (u32) n } -``` \ No newline at end of file +```