Skip to content

Commit

Permalink
Rollup merge of rust-lang#43455 - QuietMisdreavus:extend-spec-docs, r…
Browse files Browse the repository at this point in the history
…=steveklabnik

add a note to Vec's Extend<&T> impl about its slice specialization

From the regular documentation view, it's not at all apparent that [this specialization](https://github.com/rust-lang/rust/blob/5669c9988f50788b5ab5dee2d4538519d4e5663d/src/liballoc/vec.rs#L1879-L1891) exists for `slice::Iter`. This adds a documentation blurb to the Extend impl itself to note that this optimization exists.
  • Loading branch information
Mark-Simulacrum authored Jul 26, 2017
2 parents b583392 + 6e36769 commit 3751d20
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,12 @@ impl<T> Vec<T> {

}

/// Extend implementation that copies elements out of references before pushing them onto the Vec.
///
/// This implementation is specialized for slice iterators, where it uses [`copy_from_slice`] to
/// append the entire slice at once.
///
/// [`copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
#[stable(feature = "extend_ref", since = "1.2.0")]
impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
Expand Down

0 comments on commit 3751d20

Please sign in to comment.