@@ -326,83 +326,53 @@ impl<T: Clone> Clone for CVecTempl<T> {
326326
327327#[ repr( C ) ]
328328pub struct C2TupleTempl < A , B > {
329- pub a : * mut A ,
330- pub b : * mut B ,
329+ pub a : A ,
330+ pub b : B ,
331331}
332332impl < A , B > From < ( A , B ) > for C2TupleTempl < A , B > {
333333 fn from ( tup : ( A , B ) ) -> Self {
334334 Self {
335- a : Box :: into_raw ( Box :: new ( tup. 0 ) ) ,
336- b : Box :: into_raw ( Box :: new ( tup. 1 ) ) ,
335+ a : tup. 0 ,
336+ b : tup. 1 ,
337337 }
338338 }
339339}
340340impl < A , B > C2TupleTempl < A , B > {
341341 pub ( crate ) fn to_rust ( mut self ) -> ( A , B ) {
342- let res = ( unsafe { * Box :: from_raw ( self . a ) } , unsafe { * Box :: from_raw ( self . b ) } ) ;
343- self . a = std:: ptr:: null_mut ( ) ;
344- self . b = std:: ptr:: null_mut ( ) ;
345- res
342+ ( self . a , self . b )
346343 }
347344}
348345pub extern "C" fn C2TupleTempl_free < A , B > ( _res : C2TupleTempl < A , B > ) { }
349- impl < A , B > Drop for C2TupleTempl < A , B > {
350- fn drop ( & mut self ) {
351- if !self . a . is_null ( ) {
352- unsafe { Box :: from_raw ( self . a ) } ;
353- }
354- if !self . b . is_null ( ) {
355- unsafe { Box :: from_raw ( self . b ) } ;
356- }
357- }
358- }
359346impl < A : Clone , B : Clone > Clone for C2TupleTempl < A , B > {
360347 fn clone ( & self ) -> Self {
361348 Self {
362- a : Box :: into_raw ( Box :: new ( unsafe { & * self . a } . clone ( ) ) ) ,
363- b : Box :: into_raw ( Box :: new ( unsafe { & * self . b } . clone ( ) ) )
349+ a : self . a . clone ( ) ,
350+ b : self . b . clone ( )
364351 }
365352 }
366353}
367354
368355#[ repr( C ) ]
369356pub struct C3TupleTempl < A , B , C > {
370- pub a : * mut A ,
371- pub b : * mut B ,
372- pub c : * mut C ,
357+ pub a : A ,
358+ pub b : B ,
359+ pub c : C ,
373360}
374361impl < A , B , C > From < ( A , B , C ) > for C3TupleTempl < A , B , C > {
375362 fn from ( tup : ( A , B , C ) ) -> Self {
376363 Self {
377- a : Box :: into_raw ( Box :: new ( tup. 0 ) ) ,
378- b : Box :: into_raw ( Box :: new ( tup. 1 ) ) ,
379- c : Box :: into_raw ( Box :: new ( tup. 2 ) ) ,
364+ a : tup. 0 ,
365+ b : tup. 1 ,
366+ c : tup. 2 ,
380367 }
381368 }
382369}
383370impl < A , B , C > C3TupleTempl < A , B , C > {
384371 pub ( crate ) fn to_rust ( mut self ) -> ( A , B , C ) {
385- let res = ( unsafe { * Box :: from_raw ( self . a ) } , unsafe { * Box :: from_raw ( self . b ) } , unsafe { * Box :: from_raw ( self . c ) } ) ;
386- self . a = std:: ptr:: null_mut ( ) ;
387- self . b = std:: ptr:: null_mut ( ) ;
388- self . c = std:: ptr:: null_mut ( ) ;
389- res
372+ ( self . a , self . b , self . c )
390373 }
391374}
392375pub extern "C" fn C3TupleTempl_free < A , B , C > ( _res : C3TupleTempl < A , B , C > ) { }
393- impl < A , B , C > Drop for C3TupleTempl < A , B , C > {
394- fn drop ( & mut self ) {
395- if !self . a . is_null ( ) {
396- unsafe { Box :: from_raw ( self . a ) } ;
397- }
398- if !self . b . is_null ( ) {
399- unsafe { Box :: from_raw ( self . b ) } ;
400- }
401- if !self . c . is_null ( ) {
402- unsafe { Box :: from_raw ( self . c ) } ;
403- }
404- }
405- }
406376
407377/// Utility to make it easy to set a pointer to null and get its original value in line.
408378pub ( crate ) trait TakePointer < T > {
0 commit comments