Skip to content

Commit 5e0466f

Browse files
committed
Added iter function on ZendHashTable
We cannot implement `IntoIterator` for the `ZendHashTable` object as we do not manage the memory, therefore we don't actually 'consume' the object as the trait intends. Therefore, `IntoIterator` is implemented on `&'a ZendHashTable`. This `ZendHashTable::iter` function simply forwards the call.
1 parent 196ddb3 commit 5e0466f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/php/types/array.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ impl ZendHashTable {
233233
unsafe { zend_hash_next_index_insert(self.ptr, Box::into_raw(Box::new(val))) };
234234
}
235235

236+
/// Returns an iterator over the hash table.
237+
#[inline]
238+
pub fn iter(&self) -> Iter<'_> {
239+
self.into_iter()
240+
}
241+
236242
/// Converts the hash table into a raw pointer to be passed to Zend.
237243
pub(crate) fn into_ptr(mut self) -> *mut HashTable {
238244
self.free = false;

0 commit comments

Comments
 (0)