mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-26 20:15:22 +01:00
Add From<Vec<T>>
for binary types, tidy up
This commit is contained in:
parent
626c944218
commit
81dacc8cb0
@ -167,6 +167,6 @@ pub fn module(module: ModuleBuilder) -> ModuleBuilder {
|
|||||||
#[php_extern]
|
#[php_extern]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn test_func<'a>() -> Callable<'a>;
|
fn test_func<'a>() -> Callable<'a>;
|
||||||
fn strpos2<'a>(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
fn strpos2(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
||||||
pub fn strpos<'a>(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
pub fn strpos(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,7 @@ impl<'a> Arg<'a> {
|
|||||||
/// This will be None until the ArgParser is used to parse
|
/// This will be None until the ArgParser is used to parse
|
||||||
/// the arguments.
|
/// the arguments.
|
||||||
pub fn val<T: TryFrom<&'a Zval>>(&self) -> Option<T> {
|
pub fn val<T: TryFrom<&'a Zval>>(&self) -> Option<T> {
|
||||||
match self.zval {
|
self.zval.and_then(|zv| zv.try_into().ok())
|
||||||
Some(zval) => match zval.try_into() {
|
|
||||||
Ok(val) => Some(val),
|
|
||||||
Err(_) => None,
|
|
||||||
},
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to return a reference to the arguments internal Zval.
|
/// Attempts to return a reference to the arguments internal Zval.
|
||||||
|
@ -78,3 +78,9 @@ impl<T: Pack> From<Binary<T>> for Vec<T> {
|
|||||||
value.0
|
value.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Pack> From<Vec<T>> for Binary<T> {
|
||||||
|
fn from(value: Vec<T>) -> Self {
|
||||||
|
Self::new(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user