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};
19
20
21const impl<Type, const N: usize> AsRef<[Type]> for Array<Type, N> {
27 #[inline]
28 fn as_ref(&self) -> &[Type] {return unsafe {fat(self.data.as_ptr() as *const Type, self.length)}}
29}
30
31const impl<Type, const N: usize> AsMut<[Type]> for Array<Type, N> {
33 #[inline]
34 fn as_mut(&mut self) -> &mut [Type] {return unsafe {mutfat(self.pointer().as_ptr(), self.length)}}
35}
36
37
38const impl<Type, const N: usize> Borrow<[Type]> for Array<Type, N> {
44 #[inline]
45 fn borrow(&self) -> &[Type] {self.as_ref()}
46}
47
48const impl<Type, const N: usize> BorrowMut<[Type]> for Array<Type, N> {
50 #[inline]
51 fn borrow_mut(&mut self) -> &mut [Type] {self.as_mut()}
52}