Trait DefaultsArrayBoxed

Source
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

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);

Provided Methods§

Source

fn defaults<const N: usize>() -> Box<Array<Self, N>>
where Self: Default,

Create a Boxed serde_big_array::Array containing N default instances of Self.

Implementors§