Allocates `datum` in the heap and returns its pointer.
(&mut self, datum: HeapDatum)
| 248 | |
| 249 | /// Allocates `datum` in the heap and returns its pointer. |
| 250 | pub(crate) fn push(&mut self, datum: HeapDatum) -> Result<u64, HeapOverflowError> { |
| 251 | if matches!(&datum, HeapDatum::Text(s) if s.is_empty()) { |
| 252 | return Ok(self.empty_text_ptr()); |
| 253 | } |
| 254 | |
| 255 | let index = U24::try_from(self.len()).map_err(|_| HeapOverflowError)?; |
| 256 | if self.len() >= unchecked_u24_as_usize(self.max_entries) { |
| 257 | return Err(HeapOverflowError); |
| 258 | } |
| 259 | self.data.push(datum); |
| 260 | Ok(DatumPtr::for_heap(u32::from(index))) |
| 261 | } |
| 262 | |
| 263 | /// Returns the heap entry at `index`. |
| 264 | pub(crate) fn get(&self, index: usize) -> &HeapDatum { |