C++'s equal_range in Rust?

I was watching some YT video that used C++'s std::equal_range, and now I am wondering if we have something like that in Rust. I know of slice::parition_point, but I don't see a version of it that would return (usize, usize)

You can call equal_range at n and n+1. Otherwise, no.

Here's over half a decade of conversation about it:

On current stable the best answer is to call partition_point twice, for which I added some examples to the docs: More slice::partition_point examples by scottmcm · Pull Request #102507 · rust-lang/rust · GitHub

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.