Function std::storage::storable_slice::clear_slice
pub fn clear_slice(slot: b256) -> bool Expand description
Clears a slice, stored in slots of 32 bytes, from storage, starting at the slot.
Deprecation Notice
This function is deprecated in favor of clear_slice_quads, clear_slice_slot, and clear_slice_slot_existed.
To preserve exactly the same behavior as clear_slice, use clear_slice_quads.
To clear a slice contained in a single dynamic slot of variable sizes, use clear_slice_slot.
To clear a slice contained in a single dynamic slot of variable sizes, and obtain information
about whether the cleared slot was previously set, use clear_slice_slot_existed.
Arguments
slot: [b256] - The storage slot to begin clearing the slice from.
Returns
- [bool] -
trueif all of the cleared storage slots were previously set. Otherwise,false.
Number of Storage Accesses
- Reads:
1(to determine the length of the slice) - Clears:
2(one for the length of the slice, and one for the slice content)
Examples
use std::{alloc::alloc_bytes, storage::{clear_slice, write_slice, read_slice}};
fn foo() {
let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
write_slice(b256::zero(), slice);
assert(read_slice(b256::zero()).is_some());
let cleared = clear_slice(b256::zero());
assert(cleared);
assert(read_slice(b256::zero()).is_none());
}