Skip to content

Commit c902fdc

Browse files
committed
Remove unnecessary SpecFromIter impls
1 parent 7baa7af commit c902fdc

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

library/alloc/src/vec/spec_from_iter.rs

-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core::mem::ManuallyDrop;
22
use core::ptr::{self};
3-
use core::slice::{self};
43

54
use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec};
65

@@ -65,33 +64,3 @@ impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T> {
6564
vec
6665
}
6766
}
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

Comments
 (0)