pub trait DefaultsArrayBoxed {
// Provided method
fn defaults<const N: usize>() -> Box<Array<Self, N>>
where Self: Default { ... }
}Expand description
Same as DefaultsArray, but using a boxed serde_big_array::Array container
type
// usage example
use serde_big_array::Array;
use ot_tools_io::DefaultsArrayBoxed;
struct SomeType {
x: u8,
}
impl Default for SomeType {
fn default() -> Self {
Self { x: 0 }
}
}
impl DefaultsArrayBoxed for SomeType {}
let xs: Box<Array<SomeType, 20>> = SomeType::defaults();
assert_eq!(xs.len(), 20);
let xs = SomeType::defaults::<25>();
assert_eq!(xs.len(), 25);