From aaed133793229819e8911b7a9a71413649bcdf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20P=C3=A9rez-Llamas?= <932644+chris-zen@users.noreply.github.com> Date: Sat, 9 May 2020 19:13:32 +0200 Subject: [PATCH 1/2] Implement Data for Vec --- druid/src/data.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/druid/src/data.rs b/druid/src/data.rs index 66a83fe057..d4831fb7d3 100644 --- a/druid/src/data.rs +++ b/druid/src/data.rs @@ -178,6 +178,14 @@ impl Data for Result { } } +impl Data for Vec { + fn same(&self, other: &Self) -> bool { + self.iter() + .zip(other.iter()) + .all(|(a, b)| a.same(b)) + } +} + impl Data for () { fn same(&self, _other: &Self) -> bool { true @@ -387,6 +395,13 @@ impl_data_for_array! { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 } mod test { use super::Data; + #[test] + fn vec_data() { + let input = vec![1u8, 0, 0, 1, 0]; + assert!(input.same(&vec![1u8, 0, 0, 1, 0])); + assert!(!input.same(&vec![1u8, 1, 0, 1, 0])); + } + #[test] fn array_data() { let input = [1u8, 0, 0, 1, 0]; From 0fd087aeae2f975f0f8d73bc5187b20612708f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20P=C3=A9rez-Llamas?= <932644+chris-zen@users.noreply.github.com> Date: Sat, 9 May 2020 19:29:47 +0200 Subject: [PATCH 2/2] fix cargo fmt error --- druid/src/data.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/druid/src/data.rs b/druid/src/data.rs index d4831fb7d3..413ff4331e 100644 --- a/druid/src/data.rs +++ b/druid/src/data.rs @@ -180,9 +180,7 @@ impl Data for Result { impl Data for Vec { fn same(&self, other: &Self) -> bool { - self.iter() - .zip(other.iter()) - .all(|(a, b)| a.same(b)) + self.iter().zip(other.iter()).all(|(a, b)| a.same(b)) } }