diff options
| author | Paolo Barbolini <paolo@paolo565.org> | 2022-04-11 00:00:03 +0200 |
|---|---|---|
| committer | Paolo Barbolini <paolo@paolo565.org> | 2022-04-28 06:13:54 +0200 |
| commit | c126f7fc8bf9e2abc0cac1fae40d04f4cf21e4d0 (patch) | |
| tree | 1f2be7eebbe25dce4142ab74a1b8f0e57c12a347 /library/alloc/src/vec | |
| parent | 84b8898d6357810472a01038bde7b1788615aa8a (diff) | |
| download | rust-c126f7fc8bf9e2abc0cac1fae40d04f4cf21e4d0.tar.gz rust-c126f7fc8bf9e2abc0cac1fae40d04f4cf21e4d0.zip | |
Add VecDeque::extend from vec::IntoIter and slice::Iter specializations
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 5 | ||||
| -rw-r--r-- | library/alloc/src/vec/spec_extend.rs | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 03c532bb697..8134eea570a 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -121,6 +121,11 @@ impl<T, A: Allocator> IntoIter<T, A> { ptr::drop_in_place(remaining); } } + + /// Forgets to Drop the remaining elements while still allowing the backing allocation to be freed. + pub(crate) fn forget_remaining_elements(&mut self) { + self.ptr = self.end; + } } #[stable(feature = "vec_intoiter_as_ref", since = "1.46.0")] diff --git a/library/alloc/src/vec/spec_extend.rs b/library/alloc/src/vec/spec_extend.rs index c3b4534096d..506ee0ecfa2 100644 --- a/library/alloc/src/vec/spec_extend.rs +++ b/library/alloc/src/vec/spec_extend.rs @@ -62,7 +62,7 @@ impl<T, A: Allocator> SpecExtend<T, IntoIter<T>> for Vec<T, A> { unsafe { self.append_elements(iterator.as_slice() as _); } - iterator.ptr = iterator.end; + iterator.forget_remaining_elements(); } } |
