rust-lang / rust-lang/rust

Tracking Issue for BTreeMap::merge

Open
#152,152 1 comment 0 reactions 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_merge)]

This is a tracking issue for rust-lang/libs-team#739

It adds a method similar to BTreeMap::append with merging two BTreeMaps in O(n + m) complexity, but allows the user to specify a callback function to handle what the resulting value should be for conflicting keys.

Public API
// use std::collections::BTreeMap; or use alloc::collections::btree_map; 

impl <K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
    pub fn merge(&mut self, other: BTreeMap<K, V, A>, conflict: impl FnMut(&K, V, V) -> V) { ... }
}
Steps / History

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

  • ACP: rust-lang/libs-team#739
  • Implementation:
    • #151981
    • #152418
  • Optimization Issue: #153040
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • None yet.

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 BTreeMap::merge public API and feature gate btree_merge, then review implementation PRs #151981 and #152418 and optimization issue #153040. The tracking work is complete when the optimization, final comment period, and stabilization PR steps are resolved.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.