luminos_contracts/support/interacts_with_data/contains/
array.rs1use super::super::{Contains, InteractsWithData, IntoData};
2
3impl<T: PartialEq, const N: usize> Contains<T> for [T; N] {
4 fn contains_item(&self, key: &T) -> bool {
5 self.contains(key)
6 }
7}
8
9impl<T, const N: usize> InteractsWithData for [T; N] {
10 type Value = [T; N];
11 type Item = T;
12
13 fn data(&self) -> &Self::Value {
14 self
15 }
16}
17
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
24 fn test_array_interacts_with_data() {
25 let array= vec![1, 2, 3, 4];
26
27 assert_eq!(array.all(), [1, 2, 3, 4]);
28
29 assert!(array.exists(&3));
30 assert!(!array.exists(&5));
31 }
32}