#[derive(SpreadAllocate)]
Expand description

Derives ink_storage’s SpreadAllocate trait for the given struct.

Note

As of now enum types are not supported!

Examples

use ink_primitives::Key;
use ink_storage::traits::{
    SpreadAllocate,
    SpreadLayout,
    allocate_spread_root,
};

#[derive(SpreadAllocate, SpreadLayout)]
struct NamedFields {
    a: u32,
    b: [u32; 32],
}

let allocated: NamedFields = allocate_spread_root(&Key::from([0x42; 32]));
assert_eq!(
    allocated,
    NamedFields {
        a: 0,
        b: [0; 32],
    }
);