mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
Rollup merge of #43455 - QuietMisdreavus:extend-spec-docs, r=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](5669c9988f/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.
This commit is contained in:
commit
3751d20ec9
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user