cantor/array.rs
1#![allow(missing_docs)]
2#![doc(hidden)]
3
4/// Encapsulates the required operations for arrays required by this crate.
5pub trait Array<T> {
6 fn new(f: impl FnMut(usize) -> T) -> Self;
7 fn as_slice(&self) -> &[T];
8 fn as_slice_mut(&mut self) -> &mut [T];
9}
10
11impl<T, const N: usize> Array<T> for [T; N] {
12 fn new(f: impl FnMut(usize) -> T) -> Self {
13 array_init::array_init(f)
14 }
15
16 fn as_slice(&self) -> &[T] {
17 self
18 }
19
20 fn as_slice_mut(&mut self) -> &mut [T] {
21 self
22 }
23}