Skip to main content

Iterable

Enum Iterable 

Source
pub enum Iterable<'a> {
    Array(&'a ZendHashTable),
    Traversable(&'a mut ZendIterator),
}
Expand description

This type represents a PHP iterable, which can be either an array or an object implementing the Traversable interface.

An Iterable can only be extracted from a mutable Zval, via FromZvalMut. Resolving the Traversable variant invokes the Zend get_iterator handler, which mutates the object, so a shared borrow is not enough:

ⓘ
use ext_php_rs::{convert::FromZvalMut, types::{Iterable, Zval}};

fn extract(zval: &Zval) -> Option<Iterable<'_>> {
    Iterable::from_zval_mut(zval)
}

Variants§

§

Array(&'a ZendHashTable)

Iterable is an Array

§

Traversable(&'a mut ZendIterator)

Iterable is a Traversable

Implementations§

Source§

impl Iterable<'_>

Source

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

Creates a new rust iterator from a PHP iterable. May return None if a Traversable cannot be rewound.

Trait Implementations§

Source§

impl<'a> Debug for Iterable<'a>

Source§

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

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

impl<'a> FromZvalMut<'a> for Iterable<'a>

Source§

const TYPE: DataType = DataType::Iterable

The corresponding type of the implemented value in PHP.
Source§

fn from_zval_mut(zval: &'a mut Zval) -> Option<Self>

Attempts to retrieve an instance of Self from a mutable reference to a Zval. Read more
Source§

const NULLABLE: bool = false

Whether a PHP argument of this type accepts null and may be omitted.
Source§

const BY_REF: bool = false

Whether a PHP argument of this type is declared pass-by-reference (&$arg). Set it for types that mutate a PHP value in place, so the engine separates the value before the call.
Source§

fn from_missing() -> Option<Self>

The value to use when a PHP argument of this type was omitted by the caller. None means the argument is required. Read more
Source§

impl<'a> IntoIterator for &'a mut Iterable<'a>

Source§

type Item = (_zval_struct, _zval_struct)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> !Send for Iterable<'a>

§

impl<'a> !Sync for Iterable<'a>

§

impl<'a> !UnwindSafe for Iterable<'a>

§

impl<'a> Freeze for Iterable<'a>

§

impl<'a> RefUnwindSafe for Iterable<'a>

§

impl<'a> Unpin for Iterable<'a>

§

impl<'a> UnsafeUnpin for Iterable<'a>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.