Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement Data for Vec<Data>
  • Loading branch information
chris-zen committed May 9, 2020
commit aaed133793229819e8911b7a9a71413649bcdf14
15 changes: 15 additions & 0 deletions druid/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ impl<T: Data, U: Data> Data for Result<T, U> {
}
}

impl<D: Data> Data for Vec<D> {
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
Expand Down Expand Up @@ -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];
Expand Down