@@ -3176,22 +3176,22 @@ pub unsafe trait FromZeros: TryFromBytes {
31763176 <[ Self ] >:: new_box_zeroed_with_elems ( len) . map ( Into :: into)
31773177 }
31783178
3179- /// Extends a `Vec<T >` by pushing `additional` new items onto the end of the
3180- /// vector. The new items are initialized with zeros.
3179+ /// Extends a `Vec<Self >` by pushing `additional` new items onto the end of
3180+ /// the vector. The new items are initialized with zeros.
31813181 #[ cfg( zerocopy_panic_in_const_and_vec_try_reserve) ]
31823182 #[ cfg( feature = "alloc" ) ]
31833183 #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
31843184 #[ inline( always) ]
3185- fn extend_vec_zeroed < T : FromZeros > (
3186- v : & mut Vec < T > ,
3187- additional : usize ,
3188- ) -> Result < ( ) , AllocError > {
3185+ fn extend_vec_zeroed ( v : & mut Vec < Self > , additional : usize ) -> Result < ( ) , AllocError >
3186+ where
3187+ Self : Sized ,
3188+ {
31893189 // PANICS: We pass `v.len()` for `position`, so the `position > v.len()`
31903190 // panic condition is not satisfied.
3191- <T as FromZeros >:: insert_vec_zeroed ( v, v. len ( ) , additional)
3191+ <Self as FromZeros >:: insert_vec_zeroed ( v, v. len ( ) , additional)
31923192 }
31933193
3194- /// Inserts `additional` new items into `Vec<T >` at `position`. The new
3194+ /// Inserts `additional` new items into `Vec<Self >` at `position`. The new
31953195 /// items are initialized with zeros.
31963196 ///
31973197 /// # Panics
@@ -3201,11 +3201,14 @@ pub unsafe trait FromZeros: TryFromBytes {
32013201 #[ cfg( feature = "alloc" ) ]
32023202 #[ cfg_attr( doc_cfg, doc( cfg( feature = "alloc" ) ) ) ]
32033203 #[ inline]
3204- fn insert_vec_zeroed < T : FromZeros > (
3205- v : & mut Vec < T > ,
3204+ fn insert_vec_zeroed (
3205+ v : & mut Vec < Self > ,
32063206 position : usize ,
32073207 additional : usize ,
3208- ) -> Result < ( ) , AllocError > {
3208+ ) -> Result < ( ) , AllocError >
3209+ where
3210+ Self : Sized ,
3211+ {
32093212 assert ! ( position <= v. len( ) ) ;
32103213 // We only conditionally compile on versions on which `try_reserve` is
32113214 // stable; the Clippy lint is a false positive.
@@ -6291,15 +6294,15 @@ mod tests {
62916294 #[ test]
62926295 fn test_extend_vec_zeroed ( ) {
62936296 // Test extending when there is an existing allocation.
6294- let mut v = vec ! [ 100u64 , 200 , 300 ] ;
6295- u16 :: extend_vec_zeroed ( & mut v, 3 ) . unwrap ( ) ;
6297+ let mut v = vec ! [ 100u16 , 200 , 300 ] ;
6298+ FromZeros :: extend_vec_zeroed ( & mut v, 3 ) . unwrap ( ) ;
62966299 assert_eq ! ( v. len( ) , 6 ) ;
62976300 assert_eq ! ( & * v, & [ 100 , 200 , 300 , 0 , 0 , 0 ] ) ;
62986301 drop ( v) ;
62996302
63006303 // Test extending when there is no existing allocation.
63016304 let mut v: Vec < u64 > = Vec :: new ( ) ;
6302- u16 :: extend_vec_zeroed ( & mut v, 3 ) . unwrap ( ) ;
6305+ FromZeros :: extend_vec_zeroed ( & mut v, 3 ) . unwrap ( ) ;
63036306 assert_eq ! ( v. len( ) , 3 ) ;
63046307 assert_eq ! ( & * v, & [ 0 , 0 , 0 ] ) ;
63056308 drop ( v) ;
0 commit comments