1 #![allow(clippy::unnecessary_wraps)] 2 3 mod drop; 4 5 use self::drop::{DetectDrop, Flag}; 6 use anyhow::{Error, Result}; 7 use std::error::Error as StdError; 8 9 #[test] test_convert()10fn test_convert() { 11 let has_dropped = Flag::new(); 12 let error = Error::new(DetectDrop::new(&has_dropped)); 13 let box_dyn = Box::<dyn StdError + Send + Sync>::from(error); 14 assert_eq!("oh no!", box_dyn.to_string()); 15 drop(box_dyn); 16 assert!(has_dropped.get()); 17 } 18 19 #[test] test_question_mark() -> Result<(), Box<dyn StdError>>20fn test_question_mark() -> Result<(), Box<dyn StdError>> { 21 fn f() -> Result<()> { 22 Ok(()) 23 } 24 f()?; 25 Ok(()) 26 } 27