mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-30 04:39:04 +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]
|
||||
extern "C" {
|
||||
fn test_func<'a>() -> Callable<'a>;
|
||||
fn strpos2<'a>(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
||||
pub fn strpos<'a>(haystack: &str, needle: &str, offset: Option<i32>) -> Zval;
|
||||
fn strpos2(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
|
||||
/// the arguments.
|
||||
pub fn val<T: TryFrom<&'a Zval>>(&self) -> Option<T> {
|
||||
match self.zval {
|
||||
Some(zval) => match zval.try_into() {
|
||||
Ok(val) => Some(val),
|
||||
Err(_) => None,
|
||||
},
|
||||
None => None,
|
||||
}
|
||||
self.zval.and_then(|zv| zv.try_into().ok())
|
||||
}
|
||||
|
||||
/// 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
|
||||
}
|
||||
}
|
||||
|
||||
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