use family::{ any::{AnyMember, AnyOption, FamilyMember}, utils::{FamilyT, MemberT}, }; struct MemberA; type FamilyA = FamilyT; struct MemberB; type FamilyB = FamilyT; #[test] fn box_can_downcast_valid() { let member = MemberT(MemberA); let value: Box = Box::new(FamilyMember::(member)); let result = value.downcast::(); assert!(result.is_some()); } #[test] fn box_cant_downcast_invalid() { let member = MemberT(MemberB); let value: Box = Box::new(FamilyMember::(member)); let result = value.downcast::(); assert!(result.is_none()); } #[test] fn option_can_downcast_valid() { let member = MemberT(MemberA); let mut option = Some(FamilyMember::(member)); let option: &mut dyn AnyOption = &mut option; let result = option.downcast::(); assert!(result.is_some()); } #[test] fn option_cant_downcast_invalid() { let member = MemberT(MemberB); let mut option = Some(FamilyMember::(member)); let option: &mut dyn AnyOption = &mut option; let result = option.downcast::(); assert!(result.is_none()); }