WJWASFHAXBNMWHEXMKR53FLXPVUFVT44F2WKSJSA57V2UOZVSOJQC use anyhow::{bail, Result};use std::io;pub fn bail_literal() -> Result<()> {bail!("oh no!");}pub fn bail_fmt() -> Result<()> {bail!("{} {}!", "oh", "no");}pub fn bail_error() -> Result<()> {bail!(io::Error::new(io::ErrorKind::Other, "oh no!"));}
mod common;use self::common::*;use std::io;#[test]fn test_downcast() {assert_eq!("oh no!",bail_literal().unwrap_err().downcast::<&str>().unwrap(),);assert_eq!("oh no!",bail_fmt().unwrap_err().downcast::<String>().unwrap(),);assert_eq!("oh no!",bail_error().unwrap_err().downcast::<io::Error>().unwrap().to_string(),);}
}#[test]fn test_downcast() {assert_eq!("oh no!",bail_literal().unwrap_err().downcast::<&str>().unwrap(),);assert_eq!("oh no!",bail_fmt().unwrap_err().downcast::<String>().unwrap(),);assert_eq!("oh no!",bail_error().unwrap_err().downcast::<io::Error>().unwrap().to_string(),);