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
36
37
38
39
40
41
42
#[derive(Clone, Debug)]
pub struct Heaped<const N: usize, const M: usize, T>(pub Box<[T; N * M]>)
where
[T; N * M]:;
impl<const N: usize, const M: usize, T> std::ops::Index<usize> for Heaped<N, M, T>
where
[T; N * M]:,
{
type Output = T;
fn index(&self, index: usize) -> &Self::Output {
&self.0[index]
}
}
#[allow(clippy::from_over_into)]
impl<const N: usize, const M: usize, T> Into<[T; N * M]> for Heaped<N, M, T>
where
[T; N * M]:,
{
fn into(self) -> [T; N * M] {
*self.0
}
}
impl<const N: usize, const M: usize, T> From<[T; N * M]> for Heaped<N, M, T>
where
[T; N * M]:,
{
fn from(slice: [T; N * M]) -> Self {
Self::new(Box::new(slice))
}
}
impl<const N: usize, const M: usize, T> Heaped<N, M, T>
where
[T; N * M]:,
{
pub fn new(boxed_array: Box<[T; N * M]>) -> Self {
Self(boxed_array)
}
}