Skip to main content

ZArr

Struct ZArr 

Source
pub struct ZArr { /* private fields */ }
Expand description

Wrapper of zend_array.

Implementations§

Source§

impl ZArr

Source

pub unsafe fn from_ptr<'a>(ptr: *const zend_array) -> &'a Self

Wraps a raw pointer.

§Safety

Create from raw pointer.

§Panics

Panics if pointer is null.

Source

pub unsafe fn try_from_ptr<'a>(ptr: *const zend_array) -> Option<&'a Self>

Wraps a raw pointer, return None if pointer is null.

§Safety

Create from raw pointer.

Source

pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_array) -> &'a mut Self

Wraps a raw pointer.

§Safety

Create from raw pointer.

§Panics

Panics if pointer is null.

Source

pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zend_array) -> Option<&'a mut Self>

Wraps a raw pointer, return None if pointer is null.

§Safety

Create from raw pointer.

Source

pub const fn as_ptr(&self) -> *const zend_array

Returns a raw pointer wrapped.

Source

pub fn as_mut_ptr(&mut self) -> *mut zend_array

Returns a raw pointer wrapped.

Source

pub fn is_empty(&mut self) -> bool

Returns true if the array has a length of 0.

Source

pub fn len(&mut self) -> usize

Get array items length.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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);
}
Source

pub fn iter(&self) -> Iter<'_>

Provides a forward iterator.

Source

pub fn iter_mut(&mut self) -> IterMut<'_>

Provides a forward iterator with mutable references.

Trait Implementations§

Source§

impl Debug for ZArr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ZArr

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<'a> FromZVal<'a> for &'a ZArr

Source§

fn expect(val: &'a ZVal) -> Result<Self>

Converts from ZVal, return ExpectTypeError when type mismatch.
Source§

impl<'a> FromZValMut<'a> for &'a mut ZArr

Source§

fn expect(val: &'a mut ZVal) -> Result<Self>

Converts from mutable ZVal, return ExpectTypeError when type mismatch.
Source§

impl ToOwned for ZArr

Source§

type Owned = EBox<ZArr>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl ToRefOwned for ZArr

Source§

type Owned = EBox<ZArr>

The resulting type after obtaining ownership.
Source§

fn to_ref_owned(&mut self) -> Self::Owned

Creates owned data from borrowed data, by increasing refcount.

Auto Trait Implementations§

§

impl !Send for ZArr

§

impl !Sync for ZArr

§

impl Freeze for ZArr

§

impl RefUnwindSafe for ZArr

§

impl Unpin for ZArr

§

impl UnsafeUnpin for ZArr

§

impl UnwindSafe for ZArr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.