1use std::{ops, fmt};
2
3#[derive(Copy, Clone)]
5pub struct Array<T>(pub T);
6
7impl<T> Array<T> {
8 pub fn inner(&self) -> &T {
9 &self.0
10 }
11
12 pub fn inner_mut(&mut self) -> &mut T {
13 &mut self.0
14 }
15
16 pub fn into_inner(self) -> T {
17 self.0
18 }
19}
20
21impl<T> ops::Deref for Array<T> {
22 type Target = T;
23
24 fn deref(&self) -> &Self::Target {
25 &self.0
26 }
27}
28
29impl<T> ops::DerefMut for Array<T> {
30 fn deref_mut(&mut self) -> &mut Self::Target {
31 &mut self.0
32 }
33}
34
35pub trait DebugArray {
36 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result;
37}
38
39impl<T: DebugArray> fmt::Debug for Array<T> {
40 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41 T::fmt(self, f)
42 }
43}
44
45macro_rules! debug_array_impl {
46 ($array:ty) => {
47 impl ::debug_array::DebugArray for $array {
48 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
49 ::std::fmt::Debug::fmt(&self[..], f)
50 }
51 }
52 };
53}