From b0ff4baaaa1f58c802c33e4921023a7c5d43ac78 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 6 Apr 2026 09:15:40 -0600 Subject: [PATCH] Add tests for `TryFrom<&Box>` and `...&Vec>` for `Array` These have a `Clone` bound and otherwise act like the `TryFrom` impl which converts from slices by cloning their contents --- tests/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/mod.rs b/tests/mod.rs index 3fb7ab9..459ed66 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -490,6 +490,16 @@ mod allocating { ); } + #[test] + fn array_try_from_boxed_slice_ref() { + type A = Array; + assert!(A::try_from(&vec![1].into_boxed_slice()).is_err()); + assert_eq!( + &A::try_from(&vec![1, 2].into_boxed_slice()).unwrap(), + &[1, 2] + ); + } + #[test] fn array_try_from_vec() { type A = Array; @@ -497,6 +507,13 @@ mod allocating { assert_eq!(&A::try_from(vec![1, 2]).unwrap(), &[1, 2]); } + #[test] + fn array_try_from_vec_ref() { + type A = Array; + assert!(A::try_from(&vec![1]).is_err()); + assert_eq!(&A::try_from(&vec![1, 2]).unwrap(), &[1, 2]); + } + #[test] fn boxed_slice_from_array() { let array: Array = Array([1, 2, 3, 4]);