@@ -2681,6 +2681,7 @@ impl<T, const N: usize> AutoThinVec<T, N> {
26812681 debug_assert ! ( self . is_singleton( ) ) ;
26822682 let this = unsafe { self . get_unchecked_mut ( ) } ;
26832683 this. buffer . header . set_len ( 0 ) ;
2684+ // TODO(emilio): Use NonNull::from_mut when msrv allows.
26842685 this. inner . ptr = NonNull :: new_unchecked ( & mut this. buffer . header ) ;
26852686 }
26862687
@@ -2728,7 +2729,7 @@ impl<T, const N: usize> Deref for AutoThinVec<T, N> {
27282729#[ macro_export]
27292730macro_rules! auto_thin_vec {
27302731 ( let $name: ident : [ $ty: ty; $cap: literal] ) => {
2731- let mut auto_vec = $crate:: AutoThinVec :: <$ty, $cap>:: new_unpinned( ) ;
2732+ let auto_vec = $crate:: AutoThinVec :: <$ty, $cap>:: new_unpinned( ) ;
27322733 let mut $name = core:: pin:: pin!( auto_vec) ;
27332734 unsafe { $name. as_mut( ) . shrink_to_fit_known_singleton( ) } ;
27342735 } ;
@@ -4355,6 +4356,38 @@ mod std_tests {
43554356 }
43564357 */
43574358
4359+ #[ cfg( all( feature = "gecko-ffi" ) ) ]
4360+ #[ test]
4361+ fn auto_t_array_basic ( ) {
4362+ crate :: auto_thin_vec!( let t: [ u8 ; 10 ] ) ;
4363+ assert_eq ! ( t. capacity( ) , 10 ) ;
4364+ assert ! ( !t. has_allocation( ) ) ;
4365+ {
4366+ let inner = unsafe { & mut * t. as_mut ( ) . as_mut_ptr ( ) } ;
4367+ for i in 0 ..30 {
4368+ inner. push ( i as u8 ) ;
4369+ }
4370+ }
4371+
4372+ assert_eq ! ( t. len( ) , 30 ) ;
4373+ assert ! ( t. has_allocation( ) ) ;
4374+ assert_eq ! ( t[ 5 ] , 5 ) ;
4375+ assert_eq ! ( t[ 29 ] , 29 ) ;
4376+ assert ! ( t. capacity( ) >= 30 ) ;
4377+
4378+ {
4379+ let inner = unsafe { & mut * t. as_mut ( ) . as_mut_ptr ( ) } ;
4380+ inner. truncate ( 5 ) ;
4381+ }
4382+
4383+ assert_eq ! ( t. len( ) , 5 ) ;
4384+ assert ! ( t. capacity( ) >= 30 ) ;
4385+ assert ! ( t. has_allocation( ) ) ;
4386+ t. as_mut ( ) . shrink_to_fit ( ) ;
4387+ assert ! ( !t. has_allocation( ) ) ;
4388+ assert_eq ! ( t. capacity( ) , 10 ) ;
4389+ }
4390+
43584391 #[ test]
43594392 #[ cfg_attr( feature = "gecko-ffi" , ignore) ]
43604393 fn test_header_data ( ) {
0 commit comments