diff options
Diffstat (limited to 'library/alloc/src/tests.rs')
-rw-r--r-- | library/alloc/src/tests.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/library/alloc/src/tests.rs b/library/alloc/src/tests.rs index 299ed156a..b1d3a9fa8 100644 --- a/library/alloc/src/tests.rs +++ b/library/alloc/src/tests.rs @@ -4,7 +4,6 @@ use core::any::Any; use core::clone::Clone; use core::convert::TryInto; use core::ops::Deref; -use core::result::Result::{Err, Ok}; use std::boxed::Box; @@ -15,7 +14,7 @@ fn test_owned_clone() { assert!(a == b); } -#[derive(PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq)] struct Test; #[test] @@ -23,24 +22,17 @@ fn any_move() { let a = Box::new(8) as Box<dyn Any>; let b = Box::new(Test) as Box<dyn Any>; - match a.downcast::<i32>() { - Ok(a) => { - assert!(a == Box::new(8)); - } - Err(..) => panic!(), - } - match b.downcast::<Test>() { - Ok(a) => { - assert!(a == Box::new(Test)); - } - Err(..) => panic!(), - } + let a: Box<i32> = a.downcast::<i32>().unwrap(); + assert_eq!(*a, 8); + + let b: Box<Test> = b.downcast::<Test>().unwrap(); + assert_eq!(*b, Test); let a = Box::new(8) as Box<dyn Any>; let b = Box::new(Test) as Box<dyn Any>; - assert!(a.downcast::<Box<Test>>().is_err()); - assert!(b.downcast::<Box<i32>>().is_err()); + assert!(a.downcast::<Box<i32>>().is_err()); + assert!(b.downcast::<Box<Test>>().is_err()); } #[test] |