From b4b383981abac7ca8aa180c7ae3e28876615b887 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 9 Jul 2020 11:07:17 -0700 Subject: [PATCH] Add PartialEq impls for Vec <-> slice --- library/alloc/src/vec.rs | 2 ++ library/alloc/tests/vec.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..ab3f204b4a9e0 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -2398,6 +2398,8 @@ __impl_slice_eq1! { [] Vec, &[B], #[stable(feature = "rust1", since = "1.0.0" __impl_slice_eq1! { [] Vec, &mut [B], #[stable(feature = "rust1", since = "1.0.0")] } __impl_slice_eq1! { [] &[A], Vec, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] } __impl_slice_eq1! { [] &mut [A], Vec, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] } +__impl_slice_eq1! { [] Vec, [B], #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] } +__impl_slice_eq1! { [] [A], Vec, #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] } __impl_slice_eq1! { [] Cow<'_, [A]>, Vec where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } __impl_slice_eq1! { [] Cow<'_, [A]>, &[B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } __impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index ffff543b07fe5..9c278e0a0b7fb 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1594,7 +1594,7 @@ fn partialeq_vec_and_prim() { } macro_rules! assert_partial_eq_valid { - ($a2:ident, $a3:ident; $b2:ident, $b3: ident) => { + ($a2:expr, $a3:expr; $b2:expr, $b3: expr) => { assert!($a2 == $b2); assert!($a2 != $b3); assert!($a3 != $b2); @@ -1626,4 +1626,5 @@ fn partialeq_vec_full() { assert_partial_eq_valid!(slicemut2,slicemut3; vec2,vec3); assert_partial_eq_valid!(vec2,vec3; array2,array3); assert_partial_eq_valid!(vec2,vec3; arrayref2,arrayref3); + assert_partial_eq_valid!(vec2,vec3; arrayref2[..],arrayref3[..]); }