rust/library/alloc/src
Matthias Krüger e25bc303f1
Rollup merge of #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`: https://github.com/rust-lang/rust/issues/82223#issuecomment-1067098167

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.
2022-04-11 12:06:52 +02:00
..
alloc Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
boxed Add ThinBox type for 1 stack pointer sized heap allocated trait objects 2022-04-08 09:00:16 -07:00
collections add necessary closure for partition_point 2022-04-06 18:18:09 -07:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
sync Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
vec add <[[T; N]]>::flatten, <[[T; N]]>::flatten_mut, and Vec::<[T; N]>::into_flattened 2022-04-08 00:54:39 -04:00
alloc.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
borrow.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
boxed.rs Add ThinBox type for 1 stack pointer sized heap allocated trait objects 2022-04-08 09:00:16 -07:00
fmt.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
lib.rs Add ThinBox type for 1 stack pointer sized heap allocated trait objects 2022-04-08 09:00:16 -07:00
macros.rs Add diagnostic items for macros 2022-01-06 14:59:33 +00:00
raw_vec.rs formatting 2022-04-06 01:36:46 +05:30
rc.rs hide another #[allow] directive from a docs example 2022-04-08 10:29:50 -07:00
slice.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
str.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
string.rs Rework String UTF-8 Documentation 2022-04-09 09:27:32 -04:00
sync.rs hide an #[allow] directive from the Arc::new_cyclic doc example 2022-04-07 18:00:46 -07:00
task.rs Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
tests.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00