1010
1111//! The errors for crate and php.
1212
13- use crate :: {
14- alloc:: EBox , classes:: ClassEntry , objects:: ZObj , sys:: * , types:: TypeInfo , values:: ZVal ,
15- } ;
13+ use crate :: { classes:: ClassEntry , objects:: ZObject , sys:: * , types:: TypeInfo , values:: ZVal } ;
1614use derive_more:: Constructor ;
1715use phper_alloc:: ToRefOwned ;
1816use std:: {
@@ -107,9 +105,9 @@ pub trait Throwable: error::Error {
107105 ///
108106 /// By default, the Exception is instance of `get_class()`, the code is
109107 /// `get_code` and message is `get_message`;
110- fn to_object ( & mut self ) -> result:: Result < EBox < ZObj > , Box < dyn Throwable > > {
111- let mut object = EBox :: < ZObj > :: new ( self . get_class ( ) , [ ] )
112- . map_err ( |e| Box :: new ( e) as Box < dyn Throwable > ) ?;
108+ fn to_object ( & mut self ) -> result:: Result < ZObject , Box < dyn Throwable > > {
109+ let mut object =
110+ ZObject :: new ( self . get_class ( ) , [ ] ) . map_err ( |e| Box :: new ( e) as Box < dyn Throwable > ) ?;
113111 if let Some ( code) = self . get_code ( ) {
114112 object. set_property ( "code" , code) ;
115113 }
@@ -133,8 +131,7 @@ impl<T: Throwable> Throwable for Box<T> {
133131 Throwable :: get_message ( self . deref ( ) )
134132 }
135133
136- #[ allow( deprecated) ]
137- fn to_object ( & mut self ) -> result:: Result < EBox < ZObj > , Box < dyn Throwable > > {
134+ fn to_object ( & mut self ) -> result:: Result < ZObject , Box < dyn Throwable > > {
138135 Throwable :: to_object ( self . deref_mut ( ) )
139136 }
140137}
@@ -158,8 +155,7 @@ impl Throwable for Infallible {
158155 match * self { }
159156 }
160157
161- #[ allow( deprecated) ]
162- fn to_object ( & mut self ) -> result:: Result < EBox < ZObj > , Box < dyn Throwable > > {
158+ fn to_object ( & mut self ) -> result:: Result < ZObject , Box < dyn Throwable > > {
163159 match * self { }
164160 }
165161}
@@ -278,7 +274,7 @@ impl Throwable for Error {
278274 }
279275 }
280276
281- fn to_object ( & mut self ) -> result:: Result < EBox < ZObj > , Box < dyn Throwable > > {
277+ fn to_object ( & mut self ) -> result:: Result < ZObject , Box < dyn Throwable > > {
282278 match self {
283279 Error :: Io ( e) => Throwable :: to_object ( e as & mut dyn error:: Error ) ,
284280 Error :: Utf8 ( e) => Throwable :: to_object ( e as & mut dyn error:: Error ) ,
@@ -296,13 +292,13 @@ impl Throwable for Error {
296292
297293/// Wrapper of Throwable object.
298294#[ derive( Debug ) ]
299- pub struct ThrowObject ( EBox < ZObj > ) ;
295+ pub struct ThrowObject ( ZObject ) ;
300296
301297impl ThrowObject {
302298 /// Construct from Throwable object.
303299 ///
304300 /// Failed if the object is not instance of php `Throwable`.
305- pub fn new ( obj : EBox < ZObj > ) -> result:: Result < Self , NotImplementThrowableError > {
301+ pub fn new ( obj : ZObject ) -> result:: Result < Self , NotImplementThrowableError > {
306302 if !obj. get_class ( ) . is_instance_of ( throwable_class ( ) ) {
307303 return Err ( NotImplementThrowableError ) ;
308304 }
@@ -322,7 +318,7 @@ impl ThrowObject {
322318 Self :: from_result ( Throwable :: to_object ( e) )
323319 }
324320
325- fn from_result ( mut result : result:: Result < EBox < ZObj > , Box < dyn Throwable > > ) -> Self {
321+ fn from_result ( mut result : result:: Result < ZObject , Box < dyn Throwable > > ) -> Self {
326322 let mut i = 0 ;
327323
328324 let obj = loop {
@@ -343,7 +339,7 @@ impl ThrowObject {
343339
344340 /// Consumes the `ThrowObject`, returning the wrapped object.
345341 #[ inline]
346- pub fn into_inner ( self ) -> EBox < ZObj > {
342+ pub fn into_inner ( self ) -> ZObject {
347343 self . 0
348344 }
349345
@@ -390,7 +386,7 @@ impl Throwable for ThrowObject {
390386 }
391387
392388 #[ inline]
393- fn to_object ( & mut self ) -> result:: Result < EBox < ZObj > , Box < dyn Throwable > > {
389+ fn to_object ( & mut self ) -> result:: Result < ZObject , Box < dyn Throwable > > {
394390 Ok ( self . 0 . to_ref_owned ( ) )
395391 }
396392}
0 commit comments