#![cfg_attr(nightly, feature(error_generic_member_access))] mod common; #[allow(clippy::wildcard_imports)] use common::*; #[test] fn downcast_ref() { let mut report = create_report(); assert!(report.contains::()); assert!(!report.contains::()); report = report.attach(AttachmentA(10)); assert!(report.contains::()); let attachment = report .downcast_ref::() .expect("Attachment not found"); assert_eq!(attachment.0, 10); } #[test] fn downcast_mut() { let mut report = create_report(); assert!(report.contains::()); assert!(!report.contains::()); report = report.attach(AttachmentA(10)); assert!(report.contains::()); let attachment = report .downcast_mut::() .expect("Attachment not found"); attachment.0 += 10; let attachment = report .downcast_ref::() .expect("Attachment not found"); assert_eq!(attachment.0, 20); }