Skip to content

Commit 3fb7da5

Browse files
committed
Simplifying + optimizing Extend impl for Vec
1 parent 02697a2 commit 3fb7da5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/vec/extend.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ impl<T> Extend<T> for Vec<T> {
99
stream: S,
1010
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
1111
let stream = stream.into_stream();
12-
Box::pin(async move {
13-
pin_utils::pin_mut!(stream);
14-
while let Some(item) = stream.next().await {
15-
self.push(item);
16-
}
17-
})
12+
//TODO: Add this back in when size_hint is added to Stream/StreamExt
13+
//let (lower_bound, _) = stream.size_hint();
14+
//self.reserve(lower_bound);
15+
Box::pin(stream.for_each(move |item| self.push(item)))
1816
}
1917
}

0 commit comments

Comments
 (0)