rust-lang / rust-lang/rust

Tracking Issue for new `VecDeque` methods `prepend`, `extend_front`, `splice`, `extend_from_within` and `prepend_from_within`

Open
#146,975 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(deque_extend_front)]

This is a tracking issue for 5 new methods on VecDeque similar to ones already on Vec or their counterparts that push to the front instead of back.

ACP: https://github.com/rust-lang/libs-team/issues/658

Public API
// alloc::collections::vec_deque

impl<T> VecDeque<T> {
    // Preserves order of elements.
    pub fn prepend<I>(&mut self, other: I)
    where
        I: IntoIterator<Item = T>,
        I::Iter: DoubleEndedIterator
    {
        self.extend_front(other.into_iter().rev())
    }

    // Reverses order of elements.
    pub fn extend_front<I>(&mut self, other: I)
    where
        I: IntoIterator<Item = T>;

    pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<'_, I::IntoIter, A>
    where
        R: RangeBounds<usize>,
        I: IntoIterator<Item = T>;
}

impl<T: Clone> VecDeque<T> {
    pub fn extend_from_within<R>(&mut self, src: R)
    where
        R: RangeBounds<usize>;

    // Preserves order of elements.
    pub fn prepend_from_within<R>(&mut self, src: R)
    where
        R: RangeBounds<usize>;
}
Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

  • Implementation:
    • extend_front, prepend: #146861
      • specialization of deque1.prepend(deque2.drain(range)): #150595
      • part of #150597
    • extend_from_within, prepend_from_within: #147161
    • splice: #147247
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the public API in alloc::collections::vec_deque and review the implementation and discussion in PR #147247, especially the unresolved moving and allocation behavior for splice. Done means resolving remaining stabilization questions, completing the final comment period, and opening a stabilization PR.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.