pub struct ZArr { /* private fields */ }Expand description
Wrapper of zend_array.
Implementations§
Source§impl ZArr
impl ZArr
Sourcepub unsafe fn from_ptr<'a>(ptr: *const zend_array) -> &'a Self
pub unsafe fn from_ptr<'a>(ptr: *const zend_array) -> &'a Self
Sourcepub unsafe fn try_from_ptr<'a>(ptr: *const zend_array) -> Option<&'a Self>
pub unsafe fn try_from_ptr<'a>(ptr: *const zend_array) -> Option<&'a Self>
Sourcepub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_array) -> &'a mut Self
pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_array) -> &'a mut Self
Sourcepub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_array) -> Option<&'a mut Self>
pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_array) -> Option<&'a mut Self>
Sourcepub const fn as_ptr(&self) -> *const zend_array
pub const fn as_ptr(&self) -> *const zend_array
Returns a raw pointer wrapped.
Sourcepub fn as_mut_ptr(&mut self) -> *mut zend_array
pub fn as_mut_ptr(&mut self) -> *mut zend_array
Returns a raw pointer wrapped.
Sourcepub fn insert<'a>(
&mut self,
key: impl Into<InsertKey<'a>>,
value: impl Into<ZVal>,
)
pub fn insert<'a>( &mut self, key: impl Into<InsertKey<'a>>, value: impl Into<ZVal>, )
Add or update item by key.
Notice that phper prefer to use Symtables api zend_symtable_*,
so insert(42) and insert("42") should be considered the same.
Sourcepub fn get<'a>(&self, key: impl Into<Key<'a>>) -> Option<&'a ZVal>
pub fn get<'a>(&self, key: impl Into<Key<'a>>) -> Option<&'a ZVal>
Get item by key.
Notice that phper prefer to use Symtables api zend_symtable_*,
so get(42) and get("42") should be considered the same.
Sourcepub fn get_mut<'a>(&mut self, key: impl Into<Key<'a>>) -> Option<&'a mut ZVal>
pub fn get_mut<'a>(&mut self, key: impl Into<Key<'a>>) -> Option<&'a mut ZVal>
Get item by key.
Notice that phper prefer to use Symtables api zend_symtable_*,
so get_mut(42) and get_mut("42") should be considered the same.
Sourcepub fn exists<'a>(&self, key: impl Into<Key<'a>>) -> bool
pub fn exists<'a>(&self, key: impl Into<Key<'a>>) -> bool
Check if the key exists.
Notice that phper prefer to use Symtables api zend_symtable_*,
so exists(42) and exists("42") should be considered the same.
Sourcepub fn remove<'a>(&mut self, key: impl Into<Key<'a>>) -> bool
pub fn remove<'a>(&mut self, key: impl Into<Key<'a>>) -> bool
Remove the item under the key
Notice that phper prefer to use Symtables api zend_symtable_*,
so remove(42) and remove("42") should be considered the same.
Sourcepub fn entry<'a>(&'a mut self, key: impl Into<Key<'a>>) -> Entry<'a>
pub fn entry<'a>(&'a mut self, key: impl Into<Key<'a>>) -> Entry<'a>
Gets the given key’s corresponding entry in the array for in-place manipulation.
§Examples
use phper::arrays::ZArray;
let mut arr = ZArray::new();
// count the number of occurrences of letters in the vec
for x in ["a", "b", "a", "c", "a", "b"] {
arr.entry(x)
.and_modify(|cur| *cur.as_mut_long().unwrap() += 1)
.or_insert(1);
}