11use core:: mem:: ManuallyDrop ;
22use core:: ptr:: { self } ;
3- use core:: slice:: { self } ;
43
54use super :: { IntoIter , SpecExtend , SpecFromIterNested , Vec } ;
65
@@ -19,9 +18,7 @@ use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec};
1918/// |where I: | | |where I: |
2019/// | Iterator (default)----------+ | | Iterator (default) |
2120/// | vec::IntoIter | | | TrustedLen |
22- /// | SourceIterMarker---fallback-+ | | |
23- /// | slice::Iter | | |
24- /// | Iterator<Item = &Clone> | +---------------------+
21+ /// | SourceIterMarker---fallback-+ | +---------------------+
2522/// +---------------------------------+
2623/// ```
2724pub ( super ) trait SpecFromIter < T , I > {
@@ -65,33 +62,3 @@ impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T> {
6562 vec
6663 }
6764}
68-
69- impl < ' a , T : ' a , I > SpecFromIter < & ' a T , I > for Vec < T >
70- where
71- I : Iterator < Item = & ' a T > ,
72- T : Clone ,
73- {
74- default fn from_iter ( iterator : I ) -> Self {
75- SpecFromIter :: from_iter ( iterator. cloned ( ) )
76- }
77- }
78-
79- // This utilizes `iterator.as_slice().to_vec()` since spec_extend
80- // must take more steps to reason about the final capacity + length
81- // and thus do more work. `to_vec()` directly allocates the correct amount
82- // and fills it exactly.
83- impl < ' a , T : ' a + Clone > SpecFromIter < & ' a T , slice:: Iter < ' a , T > > for Vec < T > {
84- #[ cfg( not( test) ) ]
85- fn from_iter ( iterator : slice:: Iter < ' a , T > ) -> Self {
86- iterator. as_slice ( ) . to_vec ( )
87- }
88-
89- // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
90- // required for this method definition, is not available. Instead use the
91- // `slice::to_vec` function which is only available with cfg(test)
92- // NB see the slice::hack module in slice.rs for more information
93- #[ cfg( test) ]
94- fn from_iter ( iterator : slice:: Iter < ' a , T > ) -> Self {
95- crate :: slice:: to_vec ( iterator. as_slice ( ) , crate :: alloc:: Global )
96- }
97- }
0 commit comments