use snafu::prelude::*; #[derive(Debug, Snafu)] enum Error { #[snafu(display("{}", r#type))] Example { r#type: String }, r#Awesome { #[snafu(source(from(Error, Box::new)))] r#mod: Box, }, } type Result = std::result::Result; #[test] fn implements_error() { fn check() {} check::(); } #[test] fn creates_context_selectors() { fn one(success: bool) -> Result<()> { ensure!(success, ExampleSnafu { r#type: "boom" }); Ok(()) } fn two(success: bool) -> Result<()> { one(success).context(r#AwesomeSnafu)?; Ok(()) } assert!(two(true).is_ok()); assert!(two(false).is_err()); }