@@ -420,15 +420,17 @@ macro_rules! glib_boxed_wrapper {
420420
421421 ( @memory_manager_impl $name: ident $( <$( $generic: ident $( : $bound: tt $( + $bound2: tt) * ) ?) ,+>) ?, $ffi_name: ty, @copy $copy_arg: ident $copy_expr: expr, @free $free_arg: ident $free_expr: expr) => {
422422 #[ doc( hidden) ]
423- impl $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ? $crate:: boxed:: BoxedMemoryManager <$ffi_name> for $name $( <$( $generic) ,+>) ? {
423+ impl $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ? $crate:: boxed:: BoxedMemoryManager for $name $( <$( $generic) ,+>) ? {
424+ type Target = $ffi_name;
425+
424426 #[ inline]
425- unsafe fn copy( $copy_arg: * const $ffi_name ) -> * mut $ffi_name {
427+ unsafe fn copy( $copy_arg: * const Self :: Target ) -> * mut Self :: Target {
426428 $copy_expr
427429 }
428430
429431 #[ inline]
430432 #[ allow( clippy:: no_effect) ]
431- unsafe fn free( $free_arg: * mut $ffi_name ) {
433+ unsafe fn free( $free_arg: * mut Self :: Target ) {
432434 $free_expr;
433435 }
434436 }
@@ -437,21 +439,23 @@ macro_rules! glib_boxed_wrapper {
437439
438440// The safety docs really belong in the wrapper!() macro for Boxed<T>
439441/// Memory management functions for a boxed type.
440- pub trait BoxedMemoryManager < T > : ' static {
442+ pub trait BoxedMemoryManager : ' static {
443+ type Target ;
444+
441445 /// Makes a copy.
442- unsafe fn copy ( ptr : * const T ) -> * mut T ;
446+ unsafe fn copy ( ptr : * const Self :: Target ) -> * mut Self :: Target ;
443447 /// Frees the object.
444- unsafe fn free ( ptr : * mut T ) ;
448+ unsafe fn free ( ptr : * mut Self :: Target ) ;
445449}
446450
447451/// Encapsulates memory management logic for boxed types.
448452#[ repr( transparent) ]
449- pub struct Boxed < T : ' static , MM : BoxedMemoryManager < T > > {
453+ pub struct Boxed < T : ' static , MM : BoxedMemoryManager < Target = T > > {
450454 inner : ptr:: NonNull < T > ,
451455 _dummy : PhantomData < * mut MM > ,
452456}
453457
454- impl < ' a , T : ' static , MM : BoxedMemoryManager < T > > ToGlibPtr < ' a , * const T > for Boxed < T , MM > {
458+ impl < ' a , T : ' static , MM : BoxedMemoryManager < Target = T > > ToGlibPtr < ' a , * const T > for Boxed < T , MM > {
455459 type Storage = PhantomData < & ' a Self > ;
456460
457461 #[ inline]
@@ -467,7 +471,7 @@ impl<'a, T: 'static, MM: BoxedMemoryManager<T>> ToGlibPtr<'a, *const T> for Boxe
467471 }
468472}
469473
470- impl < ' a , T : ' static , MM : BoxedMemoryManager < T > > ToGlibPtrMut < ' a , * mut T > for Boxed < T , MM > {
474+ impl < ' a , T : ' static , MM : BoxedMemoryManager < Target = T > > ToGlibPtrMut < ' a , * mut T > for Boxed < T , MM > {
471475 type Storage = PhantomData < & ' a mut Self > ;
472476
473477 #[ inline]
@@ -477,7 +481,7 @@ impl<'a, T: 'static, MM: BoxedMemoryManager<T>> ToGlibPtrMut<'a, *mut T> for Box
477481 }
478482}
479483
480- impl < T : ' static , MM : BoxedMemoryManager < T > > FromGlibPtrNone < * mut T > for Boxed < T , MM > {
484+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > FromGlibPtrNone < * mut T > for Boxed < T , MM > {
481485 #[ inline]
482486 unsafe fn from_glib_none ( ptr : * mut T ) -> Self {
483487 debug_assert ! ( !ptr. is_null( ) ) ;
@@ -486,7 +490,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrNone<*mut T> for Boxed<T,
486490 }
487491}
488492
489- impl < T : ' static , MM : BoxedMemoryManager < T > > FromGlibPtrNone < * const T > for Boxed < T , MM > {
493+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > FromGlibPtrNone < * const T > for Boxed < T , MM > {
490494 #[ inline]
491495 unsafe fn from_glib_none ( ptr : * const T ) -> Self {
492496 debug_assert ! ( !ptr. is_null( ) ) ;
@@ -495,7 +499,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrNone<*const T> for Boxed<
495499 }
496500}
497501
498- impl < T : ' static , MM : BoxedMemoryManager < T > > FromGlibPtrFull < * mut T > for Boxed < T , MM > {
502+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > FromGlibPtrFull < * mut T > for Boxed < T , MM > {
499503 #[ inline]
500504 unsafe fn from_glib_full ( ptr : * mut T ) -> Self {
501505 debug_assert ! ( !ptr. is_null( ) ) ;
@@ -506,7 +510,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrFull<*mut T> for Boxed<T,
506510 }
507511}
508512
509- impl < T : ' static , MM : BoxedMemoryManager < T > > FromGlibPtrFull < * const T > for Boxed < T , MM > {
513+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > FromGlibPtrFull < * const T > for Boxed < T , MM > {
510514 #[ inline]
511515 unsafe fn from_glib_full ( ptr : * const T ) -> Self {
512516 debug_assert ! ( !ptr. is_null( ) ) ;
@@ -517,7 +521,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrFull<*const T> for Boxed<
517521 }
518522}
519523
520- impl < T : ' static , MM : BoxedMemoryManager < T > > FromGlibPtrBorrow < * mut T > for Boxed < T , MM > {
524+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > FromGlibPtrBorrow < * mut T > for Boxed < T , MM > {
521525 #[ inline]
522526 unsafe fn from_glib_borrow ( ptr : * mut T ) -> Borrowed < Self > {
523527 debug_assert ! ( !ptr. is_null( ) ) ;
@@ -528,7 +532,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrBorrow<*mut T> for Boxed<
528532 }
529533}
530534
531- impl < T : ' static , MM : BoxedMemoryManager < T > > Drop for Boxed < T , MM > {
535+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > Drop for Boxed < T , MM > {
532536 #[ inline]
533537 fn drop ( & mut self ) {
534538 unsafe {
@@ -537,36 +541,36 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> Drop for Boxed<T, MM> {
537541 }
538542}
539543
540- impl < T : ' static , MM : BoxedMemoryManager < T > > fmt:: Debug for Boxed < T , MM > {
544+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > fmt:: Debug for Boxed < T , MM > {
541545 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
542546 f. debug_struct ( "Boxed" ) . field ( "inner" , & self . inner ) . finish ( )
543547 }
544548}
545549
546- impl < T , MM : BoxedMemoryManager < T > > PartialOrd for Boxed < T , MM > {
550+ impl < T , MM : BoxedMemoryManager < Target = T > > PartialOrd for Boxed < T , MM > {
547551 #[ inline]
548552 fn partial_cmp ( & self , other : & Self ) -> Option < cmp:: Ordering > {
549553 self . to_glib_none ( ) . 0 . partial_cmp ( & other. to_glib_none ( ) . 0 )
550554 }
551555}
552556
553- impl < T , MM : BoxedMemoryManager < T > > Ord for Boxed < T , MM > {
557+ impl < T , MM : BoxedMemoryManager < Target = T > > Ord for Boxed < T , MM > {
554558 #[ inline]
555559 fn cmp ( & self , other : & Self ) -> cmp:: Ordering {
556560 self . to_glib_none ( ) . 0 . cmp ( & other. to_glib_none ( ) . 0 )
557561 }
558562}
559563
560- impl < T , MM : BoxedMemoryManager < T > > PartialEq for Boxed < T , MM > {
564+ impl < T , MM : BoxedMemoryManager < Target = T > > PartialEq for Boxed < T , MM > {
561565 #[ inline]
562566 fn eq ( & self , other : & Self ) -> bool {
563567 self . to_glib_none ( ) . 0 == other. to_glib_none ( ) . 0
564568 }
565569}
566570
567- impl < T , MM : BoxedMemoryManager < T > > Eq for Boxed < T , MM > { }
571+ impl < T , MM : BoxedMemoryManager < Target = T > > Eq for Boxed < T , MM > { }
568572
569- impl < T , MM : BoxedMemoryManager < T > > Hash for Boxed < T , MM > {
573+ impl < T , MM : BoxedMemoryManager < Target = T > > Hash for Boxed < T , MM > {
570574 #[ inline]
571575 fn hash < H > ( & self , state : & mut H )
572576 where
@@ -576,14 +580,14 @@ impl<T, MM: BoxedMemoryManager<T>> Hash for Boxed<T, MM> {
576580 }
577581}
578582
579- impl < T : ' static , MM : BoxedMemoryManager < T > > Clone for Boxed < T , MM > {
583+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > Clone for Boxed < T , MM > {
580584 #[ inline]
581585 fn clone ( & self ) -> Self {
582586 unsafe { from_glib_none ( self . to_glib_none ( ) . 0 as * mut T ) }
583587 }
584588}
585589
586- impl < T : ' static , MM : BoxedMemoryManager < T > > Deref for Boxed < T , MM > {
590+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > Deref for Boxed < T , MM > {
587591 type Target = T ;
588592
589593 #[ inline]
@@ -595,7 +599,7 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> Deref for Boxed<T, MM> {
595599 }
596600}
597601
598- impl < T : ' static , MM : BoxedMemoryManager < T > > DerefMut for Boxed < T , MM > {
602+ impl < T : ' static , MM : BoxedMemoryManager < Target = T > > DerefMut for Boxed < T , MM > {
599603 #[ inline]
600604 fn deref_mut ( & mut self ) -> & mut T {
601605 unsafe {
0 commit comments