@@ -63,7 +63,7 @@ use core::iter;
6363use core:: iter:: FromIterator ;
6464use core:: marker:: PhantomData ;
6565use core:: mem:: { self , size_of, ManuallyDrop , MaybeUninit } ;
66- use core:: ops:: { self , Bound , Index , IndexMut , Range , RangeBounds } ;
66+ use core:: ops:: { self , Bound , Index , IndexMut , RangeBounds } ;
6767use core:: ptr:: { self , NonNull } ;
6868use core:: slice:: { self , SliceIndex } ;
6969
@@ -900,7 +900,7 @@ impl<T, A: Allocator> Vec<T, A> {
900900 /// # Examples
901901 ///
902902 /// ```
903- /// use std ::collections::TryReserveError;
903+ /// use allocator_api2 ::collections::TryReserveError;
904904 ///
905905 /// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
906906 /// let mut output = Vec::new();
@@ -943,7 +943,7 @@ impl<T, A: Allocator> Vec<T, A> {
943943 /// # Examples
944944 ///
945945 /// ```
946- /// use std ::collections::TryReserveError;
946+ /// use allocator_api2 ::collections::TryReserveError;
947947 ///
948948 /// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
949949 /// let mut output = Vec::new();
@@ -1049,7 +1049,7 @@ impl<T, A: Allocator> Vec<T, A> {
10491049 let me = ManuallyDrop :: new ( self ) ;
10501050 let buf = ptr:: read ( & me. buf ) ;
10511051 let len = me. len ( ) ;
1052- buf. into_box ( len) . assume_init ( )
1052+ Box :: < [ mem :: MaybeUninit < T > ] , A > :: assume_init ( buf. into_box ( len) )
10531053 }
10541054 }
10551055
@@ -2545,62 +2545,6 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
25452545 }
25462546}
25472547
2548- trait ExtendFromWithinSpec {
2549- /// # Safety
2550- ///
2551- /// - `src` needs to be valid index
2552- /// - `self.capacity() - self.len()` must be `>= src.len()`
2553- unsafe fn spec_extend_from_within ( & mut self , src : Range < usize > ) ;
2554- }
2555-
2556- // impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
2557- // default unsafe fn spec_extend_from_within(&mut self, src: Range<usize>) {
2558- // // SAFETY:
2559- // // - len is increased only after initializing elements
2560- // let (this, spare, len) = unsafe { self.split_at_spare_mut_with_len() };
2561-
2562- // // SAFETY:
2563- // // - caller guarantees that src is a valid index
2564- // let to_clone = unsafe { this.get_unchecked(src) };
2565-
2566- // iter::zip(to_clone, spare)
2567- // .map(|(src, dst)| dst.write(src.clone()))
2568- // // Note:
2569- // // - Element was just initialized with `MaybeUninit::write`, so it's ok to increase len
2570- // // - len is increased after each element to prevent leaks (see issue #82533)
2571- // .for_each(|_| *len += 1);
2572- // }
2573- // }
2574-
2575- impl < T : Copy , A : Allocator > ExtendFromWithinSpec for Vec < T , A > {
2576- #[ inline( always) ]
2577- unsafe fn spec_extend_from_within ( & mut self , src : Range < usize > ) {
2578- let count = src. len ( ) ;
2579- {
2580- let ( init, spare) = self . split_at_spare_mut ( ) ;
2581-
2582- // SAFETY:
2583- // - caller guarantees that `src` is a valid index
2584- let source = unsafe { init. get_unchecked ( src) } ;
2585-
2586- // SAFETY:
2587- // - Both pointers are created from unique slice references (`&mut [_]`)
2588- // so they are valid and do not overlap.
2589- // - Elements are :Copy so it's OK to copy them, without doing
2590- // anything with the original values
2591- // - `count` is equal to the len of `source`, so source is valid for
2592- // `count` reads
2593- // - `.reserve(count)` guarantees that `spare.len() >= count` so spare
2594- // is valid for `count` writes
2595- unsafe { ptr:: copy_nonoverlapping ( source. as_ptr ( ) , spare. as_mut_ptr ( ) as _ , count) } ;
2596- }
2597-
2598- // SAFETY:
2599- // - The elements were just initialized by `copy_nonoverlapping`
2600- self . len += count;
2601- }
2602- }
2603-
26042548////////////////////////////////////////////////////////////////////////////////
26052549// Common trait implementations for Vec
26062550////////////////////////////////////////////////////////////////////////////////
0 commit comments