fail

Macro fail 

Source
macro_rules! fail {
    ($ctx:expr) => { ... };
}
Expand description

Utility macro to return errors.

§Arguments

  • ctx - Error context

§Example

 #[evitable(description = "Error")]
 #[derive(PartialEq)]
 pub struct Context(u8);

 fn do_fail(val: u8) -> Result<()> {
   fail!(Context(val));
   Ok(())
 }

 assert_eq!(do_fail(15).unwrap_err().context(), &Context(15));