Commit eef8bef
authored
Rollup merge of rust-lang#95743 - yaahc:binary-search-clarification, r=Mark-Simulacrum
Update binary_search example to instead redirect to partition_point
Inspired by discussion in the tracking issue for `Result::into_ok_or_err`: rust-lang#82223 (comment)
People are surprised by us not providing a `Result<T, T> -> T` conversion, and the main culprit for this confusion seems to be the `binary_search` API. We should instead redirect people to the equivalent API that implicitly does that `Result<T, T> -> T` conversion internally which should obviate the need for the `into_ok_or_err` function and give us time to work towards a more general solution that applies to all enums rather than just `Result` such as making or_patterns usable for situations like this via postfix `match`.
I choose to duplicate the example rather than simply moving it from `binary_search` to partition point because most of the confusion seems to arise when people are looking at `binary_search`. It makes sense to me to have the example presented immediately rather than requiring people to click through to even realize there is an example. If I had to put it in only one place I'd leave it in `binary_search` and remove it from `partition_point` but it seems pretty obviously relevant to `partition_point` so I figured the best option would be to duplicate it.2 files changed
+30
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2593 | 2593 | | |
2594 | 2594 | | |
2595 | 2595 | | |
2596 | | - | |
| 2596 | + | |
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
2600 | 2600 | | |
2601 | 2601 | | |
2602 | 2602 | | |
2603 | | - | |
| 2603 | + | |
| 2604 | + | |
2604 | 2605 | | |
2605 | 2606 | | |
2606 | 2607 | | |
| |||
2744 | 2745 | | |
2745 | 2746 | | |
2746 | 2747 | | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
2747 | 2761 | | |
2748 | 2762 | | |
2749 | 2763 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2331 | 2331 | | |
2332 | 2332 | | |
2333 | 2333 | | |
2334 | | - | |
| 2334 | + | |
2335 | 2335 | | |
2336 | 2336 | | |
2337 | 2337 | | |
2338 | 2338 | | |
2339 | | - | |
| 2339 | + | |
| 2340 | + | |
2340 | 2341 | | |
2341 | 2342 | | |
2342 | 2343 | | |
| |||
3743 | 3744 | | |
3744 | 3745 | | |
3745 | 3746 | | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
3746 | 3758 | | |
3747 | 3759 | | |
3748 | 3760 | | |
| |||
0 commit comments