pub trait StructToArray<Item, const N: usize>: Sized {
const N_ATOMS: usize = N;
// Required methods
fn to_arr(self) -> [Item; N];
fn from_arr(a: [Item; N]) -> Self;
// Provided method
fn num_fields() -> usize { ... }
}Expand description
Convert between a homogeneous struct (all fields of type Item) and [Item; N].
This is intentionally value-based (consumes self / takes array by value).
That keeps it safe and requires no layout assumptions.
Provided Associated Constants§
Required Methods§
Provided Methods§
fn num_fields() -> usize
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.