Skip to content

Commit f1cee2c

Browse files
committed
Auto merge of #85867 - steffahn:remove_unnecessary_specfromiter_impls, r=Mark-Simulacrum
Remove unnecessary SpecFromIter impls Unless I’m missing something, these `SpecFromIter<&'a T, …> for Vec<T>` implementations were completely unused.
2 parents cc77ba4 + 5ea3e73 commit f1cee2c

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

library/alloc/src/vec/spec_from_iter.rs

+1-34
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

@@ -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
/// ```
2724
pub(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

Comments
 (0)