libutils_array/
references.rs1use super::Array;
7
8use core::{
10 slice::{
11 from_raw_parts as fat,
12 from_raw_parts_mut as mutfat
13 },
14 borrow::{
15 Borrow,
16 BorrowMut
17 },
18 ops::{
19 Deref,
20 DerefMut
21 }
22};
23
24
25const impl<Type, const N: usize> Deref for Array<Type, N> {
31 type Target = [Type];
32 #[inline]
33 fn deref(&self) -> &Self::Target {return unsafe {fat(self.data.as_ptr() as *const Type, self.length)}}
34}
35
36const impl<Type, const N: usize> DerefMut for Array<Type, N> {
38 #[inline]
39 fn deref_mut(&mut self) -> &mut Self::Target {return unsafe {mutfat(self.pointer().as_ptr(), self.length)}}
40}
41
42const impl<Type, const N: usize> AsRef<[Type]> for Array<Type, N> {
44 #[inline]
45 fn as_ref(&self) -> &[Type] {return self.deref()}
46}
47
48const impl<Type, const N: usize> AsMut<[Type]> for Array<Type, N> {
50 #[inline]
51 fn as_mut(&mut self) -> &mut [Type] {return self.deref_mut()}
52}
53
54
55const impl<Type, const N: usize> Borrow<[Type]> for Array<Type, N> {
61 #[inline]
62 fn borrow(&self) -> &[Type] {self.as_ref()}
63}
64
65const impl<Type, const N: usize> BorrowMut<[Type]> for Array<Type, N> {
67 #[inline]
68 fn borrow_mut(&mut self) -> &mut [Type] {self.as_mut()}
69}