1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::interface::{CloneableSequence, Sequence, SequenceMut};
impl<'a, Item: 'a> Sequence<'a, Item, [Item]> for [Item] {
type Iterator = std::slice::Iter<'a, Item>;
fn iter(&'a self) -> Self::Iterator {
<[Item]>::iter(self)
}
fn len(&self) -> usize {
<[Item]>::len(self)
}
}
impl<'a, Item: 'a> SequenceMut<'a, Item, [Item]> for [Item] {
type IteratorMut = std::slice::IterMut<'a, Item>;
fn iter_mut(&'a mut self) -> Self::IteratorMut {
<[Item]>::iter_mut(self)
}
}
impl<'a, Item: 'a + Clone> CloneableSequence<'a, Item, [Item]> for [Item] {}
#[cfg(test)]
mod tests {
use crate::interface::Sequence;
#[test]
fn test_len() {
let array = [0, 1, 2];
let slice = &array[0..2];
debug_assert_eq!(2, Sequence::len(slice));
}
}