diff --git a/Cargo.toml b/Cargo.toml index 51642ab3..0d5feab5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ u256 = { package = "primitive-types", version = "0.12.1" } enum_dispatch = "0.3" arbitrary = { version = "1", features = ["derive"], optional = true } zk_evm = { git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.5.0", optional = true } -anyhow = { optional = true } +anyhow = { version = "1", optional = true } [dev-dependencies] divan = "0.1" diff --git a/src/heap.rs b/src/heap.rs index 4fc8103a..0d826838 100644 --- a/src/heap.rs +++ b/src/heap.rs @@ -20,6 +20,30 @@ impl HeapId { #[derive(Debug, Clone, PartialEq)] pub struct Heap(Vec); +impl Heap { + pub fn resize(&mut self, new_len: usize, value: u8) { + self.0.resize(new_len, value); + } + + pub fn len(&self) -> usize { + self.0.len() + } +} + +impl> std::ops::Index for Heap { + type Output = Idx::Output; + + fn index(&self, i: Idx) -> &Self::Output { + self.0.index(i) + } +} + +impl> std::ops::IndexMut for Heap { + fn index_mut(&mut self, i: Idx) -> &mut Self::Output { + self.0.index_mut(i) + } +} + impl HeapInterface for Heap { fn read_u256(&self, start_address: u32) -> U256 { self.read_u256_partially(start_address..start_address + 32)