@@ -403,6 +403,7 @@ impl<T: TransparentType> Slice<T> {
403
403
/// Borrows a C array.
404
404
#[ inline]
405
405
pub unsafe fn from_glib_borrow_num < ' a > ( ptr : * const T :: GlibType , len : usize ) -> & ' a [ T ] {
406
+ debug_assert_eq ! ( mem:: size_of:: <T >( ) , mem:: size_of:: <T :: GlibType >( ) ) ;
406
407
debug_assert ! ( !ptr. is_null( ) || len == 0 ) ;
407
408
408
409
if len == 0 {
@@ -416,6 +417,7 @@ impl<T: TransparentType> Slice<T> {
416
417
/// Borrows a mutable C array.
417
418
#[ inline]
418
419
pub unsafe fn from_glib_borrow_num_mut < ' a > ( ptr : * mut T :: GlibType , len : usize ) -> & ' a mut [ T ] {
420
+ debug_assert_eq ! ( mem:: size_of:: <T >( ) , mem:: size_of:: <T :: GlibType >( ) ) ;
419
421
debug_assert ! ( !ptr. is_null( ) || len == 0 ) ;
420
422
421
423
if len == 0 {
@@ -432,6 +434,7 @@ impl<T: TransparentType> Slice<T> {
432
434
ptr : * const * const T :: GlibType ,
433
435
len : usize ,
434
436
) -> & ' a [ & ' a T ] {
437
+ debug_assert_eq ! ( mem:: size_of:: <T >( ) , mem:: size_of:: <T :: GlibType >( ) ) ;
435
438
debug_assert ! ( !ptr. is_null( ) || len == 0 ) ;
436
439
437
440
if len == 0 {
@@ -448,6 +451,7 @@ impl<T: TransparentType> Slice<T> {
448
451
ptr : * mut * mut T :: GlibType ,
449
452
len : usize ,
450
453
) -> & ' a mut [ & ' a mut T ] {
454
+ debug_assert_eq ! ( mem:: size_of:: <T >( ) , mem:: size_of:: <T :: GlibType >( ) ) ;
451
455
debug_assert ! ( !ptr. is_null( ) || len == 0 ) ;
452
456
453
457
if len == 0 {
@@ -522,6 +526,8 @@ impl<T: TransparentType> Slice<T> {
522
526
/// Creates a new empty slice.
523
527
#[ inline]
524
528
pub fn new ( ) -> Self {
529
+ debug_assert_eq ! ( mem:: size_of:: <T >( ) , mem:: size_of:: <T :: GlibType >( ) ) ;
530
+
525
531
Slice {
526
532
ptr : ptr:: NonNull :: dangling ( ) ,
527
533
len : 0 ,
0 commit comments