Skip to content

Commit

Permalink
add back sort_by_key link, allow linter and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Mar 10, 2021
1 parent 14e23f1 commit 0d07153
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ impl<T> [T] {
/// Binary searches this sorted slice with a key extraction function.
///
/// Assumes that the slice is sorted by the key, for instance with
/// `sort_by_key` using the same key extraction function.
/// [`sort_by_key`] using the same key extraction function.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
Expand All @@ -2225,6 +2225,7 @@ impl<T> [T] {
///
/// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
///
/// [`sort_by_key`]: slice::sort_by_key
/// [`binary_search`]: slice::binary_search
/// [`binary_search_by`]: slice::binary_search_by
/// [`partition_point`]: slice::partition_point
Expand All @@ -2247,6 +2248,10 @@ impl<T> [T] {
/// let r = s.binary_search_by_key(&1, |&(a, b)| b);
/// assert!(match r { Ok(1..=4) => true, _ => false, });
/// ```
// Lint rustdoc::broken_intra_doc_links is allowed as `slice::sort_by_key` is
// in crate `alloc`, and as such doesn't exists yet when building `core`
// links to downstream crate: https://github.com/rust-lang/rust/issues/74481
#[cfg_attr(not(bootstrap), allow(rustdoc::broken_intra_doc_links))]
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
#[inline]
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize>
Expand Down

0 comments on commit 0d07153

Please sign in to comment.