@@ -967,30 +967,28 @@ macro_rules! glib_object_wrapper {
967
967
968
968
#[ doc( hidden) ]
969
969
impl <' a $( , $( $generic $( : $bound $( + $bound2) * ) ?) ,+) ?> $crate:: translate:: ToGlibContainerFromSlice <' a, * mut * mut $ffi_name> for $name $( <$( $generic) ,+>) ? {
970
- type Storage = ( Vec <$crate :: translate :: Stash < ' a , * mut $ffi_name , Self > >, Option <Vec <* mut $ffi_name>>) ;
970
+ type Storage = ( std :: marker :: PhantomData < & ' a [ Self ] >, Option <Vec <* mut $ffi_name>>) ;
971
971
972
972
fn to_glib_none_from_slice( t: & ' a [ Self ] ) -> ( * mut * mut $ffi_name, Self :: Storage ) {
973
- let v : Vec <_> = t . iter ( ) . map ( |s| $crate :: translate :: ToGlibPtr :: to_glib_none ( s ) ) . collect ( ) ;
974
- let mut v_ptr: Vec <_> = v . iter( ) . map( |s| s . 0 ) . collect ( ) ;
975
- v_ptr. push( std:: ptr:: null_mut( ) as * mut $ffi_name ) ;
973
+ let mut v_ptr = Vec :: with_capacity ( t . len ( ) + 1 ) ;
974
+ v_ptr. extend ( t . iter( ) . map( |t| < Self as $crate :: ObjectType > :: as_ptr ( t ) ) ) ;
975
+ v_ptr. push( std:: ptr:: null_mut( ) ) ;
976
976
977
- ( v_ptr. as_ptr( ) as * mut * mut $ffi_name, ( v , Some ( v_ptr) ) )
977
+ ( v_ptr. as_ptr( ) as * mut * mut $ffi_name, ( std :: marker :: PhantomData , Some ( v_ptr) ) )
978
978
}
979
979
980
980
fn to_glib_container_from_slice( t: & ' a [ Self ] ) -> ( * mut * mut $ffi_name, Self :: Storage ) {
981
- let v: Vec <_> = t. iter( ) . map( |s| $crate:: translate:: ToGlibPtr :: to_glib_none( s) ) . collect( ) ;
982
-
983
981
let v_ptr = unsafe {
984
982
let v_ptr = $crate:: ffi:: g_malloc0( std:: mem:: size_of:: <* mut $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * mut $ffi_name;
985
983
986
- for ( i, s ) in v . iter( ) . enumerate( ) {
987
- std:: ptr:: write( v_ptr. add( i) , s . 0 ) ;
984
+ for ( i, t ) in t . iter( ) . enumerate( ) {
985
+ std:: ptr:: write( v_ptr. add( i) , < Self as $crate :: ObjectType > :: as_ptr ( t ) ) ;
988
986
}
989
987
990
988
v_ptr
991
989
} ;
992
990
993
- ( v_ptr, ( v , None ) )
991
+ ( v_ptr, ( std :: marker :: PhantomData , None ) )
994
992
}
995
993
996
994
fn to_glib_full_from_slice( t: & [ Self ] ) -> * mut * mut $ffi_name {
@@ -1008,7 +1006,7 @@ macro_rules! glib_object_wrapper {
1008
1006
1009
1007
#[ doc( hidden) ]
1010
1008
impl <' a $( , $( $generic $( : $bound $( + $bound2) * ) ?) ,+) ?> $crate:: translate:: ToGlibContainerFromSlice <' a, * const * mut $ffi_name> for $name $( <$( $generic) ,+>) ? {
1011
- type Storage = ( Vec <$crate :: translate :: Stash < ' a , * mut $ffi_name , Self > >, Option <Vec <* mut $ffi_name>>) ;
1009
+ type Storage = ( std :: marker :: PhantomData < & ' a [ Self ] >, Option <Vec <* mut $ffi_name>>) ;
1012
1010
1013
1011
fn to_glib_none_from_slice( t: & ' a [ Self ] ) -> ( * const * mut $ffi_name, Self :: Storage ) {
1014
1012
let ( ptr, stash) = $crate:: translate:: ToGlibContainerFromSlice :: <' a, * mut * mut $ffi_name>:: to_glib_none_from_slice( t) ;
0 commit comments