rust-lang / rust-lang/rust

Tracking Issue for `BTreeSet` entry APIs

Open
#133,549 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Feature gate: #![feature(btree_set_entry)]

This is a tracking issue for Entry and entry-like methods on BTreeSet.

Public API
impl<T, A: Allocator + Clone> BTreeSet<T, A> {
    pub fn get_or_insert(&mut self, value: T) -> &T
    where
        T: Ord,
    {...}
    pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T
    where
        T: Borrow<Q> + Ord,
        Q: Ord,
        F: FnOnce(&Q) -> T,
    {...}

    pub fn entry(&mut self, value: T) -> Entry<'_, T, A>
    where
        T: Ord,
    {...}
}

pub enum Entry<'a, T, A: Allocator + Clone = Global> {
    Occupied(OccupiedEntry<'a, T, A>),
    Vacant(VacantEntry<'a, T, A>),
}
pub struct OccupiedEntry<'a, T, A: Allocator + Clone = Global> {...}
pub struct VacantEntry<'a, T, A: Allocator + Clone = Global> {...}

impl<T: Debug + Ord, A: Allocator + Clone> Debug for Entry<'_, T, A> {...}
impl<T: Debug + Ord, A: Allocator + Clone> Debug for OccupiedEntry<'_, T, A> {...}
impl<T: Debug + Ord, A: Allocator + Clone> Debug for VacantEntry<'_, T, A> {...}

impl<'a, T: Ord, A: Allocator + Clone> Entry<'a, T, A> {
    pub fn insert(self) -> OccupiedEntry<'a, T, A> {...}
    pub fn or_insert(self) {...}
    pub fn get(&self) -> &T {...}
}

impl<'a, T: Ord, A: Allocator + Clone> OccupiedEntry<'a, T, A> {
    pub fn get(&self) -> &T {...}
    pub fn remove(self) -> T {...}
}

impl<'a, T: Ord, A: Allocator + Clone> VacantEntry<'a, T, A> {
    pub fn get(&self) -> &T {...}
    pub fn into_value(self) -> T {...}
    pub fn insert(self) {...}
}
Steps / History
  • Implementation: #133548
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • None yet.

See also #60896 for HashSet.

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

This is a tracking issue for the BTreeSet entry APIs, with implementation recorded as complete in #133548. Start by reviewing that implementation and the stabilization guidance linked in the issue; done means completing the remaining FCP and stabilization steps, but no files or tests are named here.

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
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.