Skip to content

Commit

Permalink
Add extract function to Zval
Browse files Browse the repository at this point in the history
  • Loading branch information
vodik committed Oct 3, 2021
1 parent dca53ea commit 5ada199
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/php/types/zval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,16 @@ impl Zval {
unsafe { zval_ptr_dtor(self) };
self.u1.type_info = ty.bits();
}

/// Extracts some type from a `Zval`.
///
/// This is a wrapper function around `TryFrom`.
pub fn extract<'a, T>(&'a self) -> Option<T>
where
T: FromZval<'a>,
{
FromZval::from_zval(self)
}
}

impl Debug for Zval {
Expand Down

0 comments on commit 5ada199

Please sign in to comment.