[−][src]Macro bail_out::ensure_not
Return early with an error if the condition is true. This ensures the condition is not met.
This macro is equivalent to if cond { return Err(error) }
.
Example:
use bail_out::*; fn test_err() -> Result<(), &'static str> { ensure_not!(true, "error"); Ok(()) } assert_eq!(test_err(), Err("error")); fn test_ok() -> Result<(), &'static str> { ensure_not!(false, "ok"); Ok(()) } assert_eq!(test_ok(), Ok(()));