Skip to content

Commit

Permalink
Clarify docs for when binary_search has many matches.
Browse files Browse the repository at this point in the history
Fixes #51817.
  • Loading branch information
frewsxcv committed Oct 7, 2018
1 parent 1886d5f commit b5c64e2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/libcore/slice/mod.rs
Expand Up @@ -1174,9 +1174,10 @@ impl<T> [T] {

/// Binary searches this sorted slice for a given element.
///
/// If the value is found then `Ok` is returned, containing the
/// index of the matching element; if the value is not found then
/// `Err` is returned, containing the index where a matching
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
/// one of the matches could be returned. If the value is not found then
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// # Examples
Expand Down Expand Up @@ -1208,9 +1209,10 @@ impl<T> [T] {
/// order code that indicates whether its argument is `Less`,
/// `Equal` or `Greater` the desired target.
///
/// If a matching value is found then returns `Ok`, containing
/// the index for the matched element; if no match is found then
/// `Err` is returned, containing the index where a matching
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
/// one of the matches could be returned. If the value is not found then
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// # Examples
Expand Down Expand Up @@ -1264,10 +1266,11 @@ impl<T> [T] {
/// Assumes that the slice is sorted by the key, for instance with
/// [`sort_by_key`] using the same key extraction function.
///
/// If a matching value is found then returns `Ok`, containing the
/// index for the matched element; if no match is found then `Err`
/// is returned, containing the index where a matching element could
/// be inserted while maintaining sorted order.
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
/// one of the matches could be returned. If the value is not found then
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// [`sort_by_key`]: #method.sort_by_key
///
Expand Down

0 comments on commit b5c64e2

Please sign in to comment.