[−][src]Macro bail_out::assure_not_or
Ensures the condition is not met or returns the value. This evaluates to a Result<VALUE, ERROR>
This macro is equivalent to if cond { Err(error) } else { Ok(value) }
.
Example:
use bail_out::*; fn test_err() -> Result<&'static str, &'static str> { assure_not_or!(true, "ok", "error") } assert_eq!(test_err(), Err("error")); fn test_ok() -> Result<&'static str, &'static str> { assure_not_or!(false, "ok", "error") } assert_eq!(test_ok(), Ok("ok"));