spinoso_array/array/vec/
impls.rs

1use core::ops::{Deref, DerefMut, Index, IndexMut};
2use core::slice::SliceIndex;
3
4use super::Array;
5
6impl<T> AsRef<[T]> for Array<T> {
7    #[inline]
8    fn as_ref(&self) -> &[T] {
9        self.0.as_ref()
10    }
11}
12
13impl<T> AsMut<[T]> for Array<T> {
14    #[inline]
15    fn as_mut(&mut self) -> &mut [T] {
16        self.0.as_mut()
17    }
18}
19
20impl<T> Deref for Array<T> {
21    type Target = [T];
22
23    #[inline]
24    fn deref(&self) -> &Self::Target {
25        &self.0
26    }
27}
28
29impl<T> DerefMut for Array<T> {
30    #[inline]
31    fn deref_mut(&mut self) -> &mut Self::Target {
32        &mut self.0
33    }
34}
35
36impl<T> Extend<T> for Array<T> {
37    #[inline]
38    fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
39        self.0.extend(iter);
40    }
41}
42
43impl<'a, T> Extend<&'a T> for Array<T>
44where
45    T: 'a + Copy,
46{
47    #[inline]
48    fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
49        self.0.extend(iter);
50    }
51}
52
53impl<T, I> Index<I> for Array<T>
54where
55    I: SliceIndex<[T]>,
56{
57    type Output = I::Output;
58
59    #[inline]
60    fn index(&self, index: I) -> &I::Output {
61        &self.0[index]
62    }
63}
64
65impl<T, I> IndexMut<I> for Array<T>
66where
67    I: SliceIndex<[T]>,
68{
69    #[inline]
70    fn index_mut(&mut self, index: I) -> &mut I::Output {
71        &mut self.0[index]
72    }
73}