pub fn clear_slice_slot_existed(slot: b256) -> bool 
Expand description

Clears a slice from storage, stored in a single dynamic slot, and returns whether the cleared slot was previously set.

Arguments

  • slot: [b256] - The storage slot to clear the slice from.

Returns

  • [bool] - true if the cleared storage slot was previously set. Otherwise, false.

Number of Storage Accesses

  • Preload: 1 (to determine if the slot was previously set)
  • Clears: 1 (for the slice content)

Examples

use std::{alloc::alloc_bytes, storage::{clear_slice_slot_existed, write_slice_slot, read_slice_slot}};

fn foo() {
    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
    write_slice_slot(b256::zero(), slice);
    assert(read_slice_slot(b256::zero()).is_some());
    let cleared = clear_slice_slot_existed(b256::zero());
    assert(cleared);
    assert(read_slice_slot(b256::zero()).is_none());
}