Skip to content

Commit 3d9f901

Browse files
committed
generalize SizedArray
1 parent 2ebad26 commit 3d9f901

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/dependent_array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ pub trait Discriminant<const IN: usize> {
1010
/// which is guaranteed to have the constant size.
1111
pub trait CheckedArray<const IN: usize>: Discriminant<IN> {
1212
/// The [`SizedArray`]
13-
type Array<T>: SizedArray + TryFrom<Vec<T>> + Into<Vec<T>> + IntoIterator<Item = T>;
13+
type Array<T>: SizedArray<T>;
1414
}
1515

1616
/// Only implemented for arrays to allow to use their sizes
1717
/// as a constant at compile time.
18-
pub trait SizedArray {
18+
pub trait SizedArray<T>: TryFrom<Vec<T>> + Into<Vec<T>> + IntoIterator<Item = T> {
1919
/// The size of the array.
2020
const SIZE: usize;
2121
}
2222

2323
// Implement for all fixed-size arrays
24-
impl<const N: usize, T> SizedArray for [T; N] {
24+
impl<const N: usize, T> SizedArray<T> for [T; N] {
2525
const SIZE: usize = N;
2626
}
2727

@@ -40,7 +40,7 @@ impl<const IN: usize, ARR> VerifySize<IN, ARR> for ARR
4040
where
4141
ARR: CheckedArray<IN>,
4242
{
43-
const ASSERT_SIZE: () = assert!(<ARR::Array<()> as SizedArray>::SIZE == ARR::ARR_SIZE);
43+
const ASSERT_SIZE: () = assert!(<ARR::Array<()> as SizedArray<()>>::SIZE == ARR::ARR_SIZE);
4444
}
4545

4646
#[derive(Debug, Copy, Clone)]

0 commit comments

Comments
 (0)