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
// devela::data::array
//
//! Arrays are random-access, sequentially allocated, statically sized,
//! homogeneous data structures.
//

#[cfg(feature = "alloc")]
use crate::mem::Boxed;
use crate::mem::Storage;

mod core_impls;
mod methods;
// mod traits;

/// An array, backed by the core [`array`] primitive.
pub struct Array<T, S: Storage, const LEN: usize> {
    array: S::Stored<[T; LEN]>,
}

/// An [`Array`] stored in the heap.
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub type BoxedArray<T, const LEN: usize> = Array<T, Boxed, LEN>;

/// An [`Array`] stored in the stack.
pub type DirectArray<T, const LEN: usize> = Array<T, (), LEN>;

pub use all::*;
pub(crate) mod all {
    #[doc(inline)]
    #[cfg(feature = "alloc")]
    pub use super::BoxedArray;

    #[doc(inline)]
    pub use super::{Array, DirectArray};
}