66
77use crate :: ffi:: zend_string;
88
9- use std:: { convert :: TryFrom , ops:: Deref , slice:: from_raw_parts} ;
9+ use std:: { ops:: Deref , slice:: from_raw_parts} ;
1010
11- use crate :: {
12- convert:: FromZval ,
13- error:: { Error , Result } ,
14- flags:: DataType ,
15- types:: Zval ,
16- } ;
11+ use crate :: { convert:: FromZval , flags:: DataType , types:: Zval } ;
1712
18- /// Acts as a wrapper around [ `&[T]`] where `T` implements [`PackSlice`].
13+ /// Acts as a wrapper around `&[T]` where `T` implements [`PackSlice`].
1914/// Primarily used for passing read-only binary data into Rust functions.
2015#[ derive( Debug ) ]
2116pub struct BinarySlice < ' a , T > ( & ' a [ T ] )
@@ -47,28 +42,17 @@ where
4742 }
4843}
4944
50- impl < T > FromZval < ' _ > for BinarySlice < ' _ , T >
45+ impl < ' a , T > FromZval < ' a > for BinarySlice < ' a , T >
5146where
5247 T : PackSlice ,
5348{
5449 const TYPE : DataType = DataType :: String ;
5550
56- fn from_zval ( zval : & Zval ) -> Option < Self > {
51+ fn from_zval ( zval : & ' a Zval ) -> Option < Self > {
5752 zval. binary_slice ( ) . map ( BinarySlice )
5853 }
5954}
6055
61- impl < T > TryFrom < Zval > for BinarySlice < ' _ , T >
62- where
63- T : PackSlice ,
64- {
65- type Error = Error ;
66-
67- fn try_from ( value : Zval ) -> Result < Self > {
68- Self :: from_zval ( & value) . ok_or_else ( || Error :: ZvalConversion ( value. get_type ( ) ) )
69- }
70- }
71-
7256impl < ' a , T > From < BinarySlice < ' a , T > > for & ' a [ T ]
7357where
7458 T : PackSlice ,
@@ -117,7 +101,7 @@ pub unsafe trait PackSlice: Clone {
117101 /// * `s` - The Zend string containing the binary data.
118102 ///
119103 /// [`pack`]: https://www.php.net/manual/en/function.pack.php
120- fn unpack_into < ' a > ( s : & zend_string ) -> & ' a [ Self ] ;
104+ fn unpack_into ( s : & zend_string ) -> & [ Self ] ;
121105}
122106
123107/// Implements the [`PackSlice`] trait for a given type.
@@ -128,7 +112,7 @@ macro_rules! pack_slice_impl {
128112
129113 ( $t: ty, $d: expr) => {
130114 unsafe impl PackSlice for $t {
131- fn unpack_into< ' a> ( s: & zend_string) -> & ' a [ Self ] {
115+ fn unpack_into( s: & zend_string) -> & [ Self ] {
132116 let bytes = ( $d / 8 ) as usize ;
133117 let len = ( s. len as usize ) / bytes;
134118 let ptr = s. val. as_ptr( ) as * const $t;
0 commit comments