Function std::storage::storage_api::clear_slots_existed
pub fn clear_slots_existed(slot: b256, number_of_slots: u64) -> bool Expand description
Clears number_of_slots slots of dynamic size, starting at slot,
and returns whether all the cleared slots were previously set.
Additional Information
If number_of_slots is zero, storage access will still occur,
but no slots will be cleared.
If number_of_slots is zero, function always returns true,
regardless of the slot.
Arguments
slot: [b256] - The storage slot from which to start clearing.number_of_slots: [u64] - The number of slots to clear.
Returns
- [bool] -
trueif all the cleared storage slots were previously set. Otherwise,false.
Number of Storage Accesses
- Preloads:
number_of_slots(to check whether the slots were previously set) - Clears:
1
Examples
use std::storage::storage_api::{read_slot, write_slot, clear_slots_existed};
fn foo() {
let five = 5_u64;
write_slot(b256::zero(), five);
let cleared = clear_slots_existed(b256::zero(), 1);
assert(cleared);
assert(read_slot::<u64>(b256::zero(), 0).is_none());
}