9292 clippy:: undocumented_unsafe_blocks
9393) ]
9494
95- use core:: borrow:: { Borrow , BorrowMut } ;
96- use core:: cmp:: Ordering ;
97- use core:: fmt;
98- use core:: hash:: { self , Hash } ;
99- use core:: iter:: FusedIterator ;
100- use core:: marker:: PhantomData ;
101- use core:: mem;
102- use core:: ops;
103- use core:: ops:: Bound :: { Excluded , Included , Unbounded } ;
104- use core:: ops:: { Index , IndexMut , RangeBounds } ;
105- use core:: ptr;
106- use core:: ptr:: NonNull ;
107- use core:: slice;
95+ use std:: {
96+ borrow:: { Borrow , BorrowMut } ,
97+ cmp:: Ordering ,
98+ fmt,
99+ hash:: { self , Hash } ,
100+ hint,
101+ iter:: FusedIterator ,
102+ marker:: PhantomData ,
103+ mem,
104+ ops:: {
105+ self ,
106+ Bound :: { Excluded , Included , Unbounded } ,
107+ Index , IndexMut , RangeBounds ,
108+ } ,
109+ ptr:: { self , NonNull } ,
110+ slice:: { self , SliceIndex } ,
111+ } ;
108112
109113// #[cfg(feature = "std")]
110114// use std::io;
@@ -1031,9 +1035,12 @@ impl<'a, T: 'a, A: Alloc> Vec<'a, T, A> {
10311035 // We shadow the slice method of the same name to avoid going through
10321036 // `deref`, which creates an intermediate reference.
10331037 let ptr = self . buf . ptr ( ) ;
1038+ // Note: We could use `assert_unchecked!` here, but that would introduce a debug assertion
1039+ // for a trivially satisfied invariant.
1040+ // This is a hot path, so that could measurably slow down debug builds.
10341041 unsafe {
10351042 if ptr. is_null ( ) {
1036- core :: hint:: unreachable_unchecked ( ) ;
1043+ hint:: unreachable_unchecked ( ) ;
10371044 }
10381045 }
10391046 ptr
@@ -1073,9 +1080,12 @@ impl<'a, T: 'a, A: Alloc> Vec<'a, T, A> {
10731080 // We shadow the slice method of the same name to avoid going through
10741081 // `deref_mut`, which creates an intermediate reference.
10751082 let ptr = self . buf . ptr ( ) ;
1083+ // Note: We could use `assert_unchecked!` here, but that would introduce a debug assertion
1084+ // for a trivially satisfied invariant.
1085+ // This is a hot path, so that could measurably slow down debug builds.
10761086 unsafe {
10771087 if ptr. is_null ( ) {
1078- core :: hint:: unreachable_unchecked ( ) ;
1088+ hint:: unreachable_unchecked ( ) ;
10791089 }
10801090 }
10811091 ptr
@@ -2057,10 +2067,7 @@ impl<'a, T: 'a + Hash, A: Alloc> Hash for Vec<'a, T, A> {
20572067 }
20582068}
20592069
2060- impl < T , A : Alloc , I > Index < I > for Vec < ' _ , T , A >
2061- where
2062- I : :: core:: slice:: SliceIndex < [ T ] > ,
2063- {
2070+ impl < T , A : Alloc , I : SliceIndex < [ T ] > > Index < I > for Vec < ' _ , T , A > {
20642071 type Output = I :: Output ;
20652072
20662073 #[ inline]
@@ -2069,10 +2076,7 @@ where
20692076 }
20702077}
20712078
2072- impl < T , A : Alloc , I > IndexMut < I > for Vec < ' _ , T , A >
2073- where
2074- I : :: core:: slice:: SliceIndex < [ T ] > ,
2075- {
2079+ impl < T , A : Alloc , I : SliceIndex < [ T ] > > IndexMut < I > for Vec < ' _ , T , A > {
20762080 #[ inline]
20772081 fn index_mut ( & mut self , index : I ) -> & mut Self :: Output {
20782082 IndexMut :: index_mut ( & mut * * self , index)
0 commit comments