Skip to content

BTreeMap::split_off should mention that the key don't need to be exact #147174

Description

@ultimaweapon

Location (URL)

https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.split_off

Summary

The following code is working (as expected?):

use std::collections::BTreeMap;

fn main() {
    let mut a = BTreeMap::new();
    
    a.insert(1, "a");
    a.insert(2, "b");
    a.insert(3, "c");
    a.insert(17, "d");
    a.insert(41, "e");
    
    let b = a.split_off(&4);
    
    assert_eq!(a.len(), 3);
    assert_eq!(b.len(), 2);
}

Notice the split_off call with the key that does not exists in the tree.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions