@@ -15,7 +15,6 @@ use crate::{
1515} ;
1616use std:: convert:: Infallible ;
1717use std:: marker:: PhantomData ;
18- use std:: mem:: transmute;
1918
2019/// Defines a conversion from a Rust type to a Python object, which may fail.
2120///
@@ -150,7 +149,7 @@ impl<'a, 'py, T: PyTypeCheck> IntoPyObject<'py> for &'a Bound<'_, T> {
150149 const OUTPUT_TYPE : PyStaticExpr = T :: TYPE_HINT ;
151150
152151 fn into_pyobject ( self , py : Python < ' py > ) -> Result < Self :: Output , Self :: Error > {
153- Ok ( self . as_unbound ( ) . bind_borrowed ( py) )
152+ Ok ( self . as_unbound ( ) . bind_borrowed ( py) )
154153 }
155154}
156155
@@ -162,8 +161,8 @@ impl<'a, 'py, T: PyTypeCheck> IntoPyObject<'py> for Borrowed<'a, '_, T> {
162161 #[ cfg( feature = "experimental-inspect" ) ]
163162 const OUTPUT_TYPE : PyStaticExpr = T :: TYPE_HINT ;
164163
165- fn into_pyobject ( self , _py : Python < ' py > ) -> Result < Self :: Output , Self :: Error > {
166- unsafe { Ok ( transmute ( self ) ) }
164+ fn into_pyobject ( self , py : Python < ' py > ) -> Result < Self :: Output , Self :: Error > {
165+ Ok ( self . as_unbound ( ) . bind_borrowed ( py ) )
167166 }
168167}
169168
@@ -175,8 +174,8 @@ impl<'a, 'py, T: PyTypeCheck> IntoPyObject<'py> for &Borrowed<'a, '_, T> {
175174 #[ cfg( feature = "experimental-inspect" ) ]
176175 const OUTPUT_TYPE : PyStaticExpr = T :: TYPE_HINT ;
177176
178- fn into_pyobject ( self , _py : Python < ' py > ) -> Result < Self :: Output , Self :: Error > {
179- unsafe { Ok ( transmute ( * self ) ) }
177+ fn into_pyobject ( self , py : Python < ' py > ) -> Result < Self :: Output , Self :: Error > {
178+ Ok ( self . as_unbound ( ) . bind_borrowed ( py ) )
180179 }
181180}
182181
0 commit comments