Skip to content

Commit

Permalink
Rollup merge of rust-lang#81012 - VillSnow:stabilize_partition_point,…
Browse files Browse the repository at this point in the history
… r=matklad

Stabilize the partition_point feature

Stabilize the partition_point feature.
Tracking Issue: rust-lang#73831
First PR: rust-lang#73577
  • Loading branch information
Dylan-DPC authored Feb 12, 2021
2 parents ab3f4f0 + afdc8c7 commit 8280abc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 24 additions & 3 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,12 @@ impl<T> [T] {
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`binary_search_by`]: #method.binary_search_by
/// [`binary_search_by_key`]: #method.binary_search_by_key
/// [`partition_point`]: #method.partition_point
///
/// # Examples
///
/// Looks up a series of four elements. The first is found, with a
Expand Down Expand Up @@ -2129,6 +2135,12 @@ impl<T> [T] {
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`binary_search`]: #method.binary_search
/// [`binary_search_by_key`]: #method.binary_search_by_key
/// [`partition_point`]: #method.partition_point
///
/// # Examples
///
/// Looks up a series of four elements. The first is found, with a
Expand Down Expand Up @@ -2186,7 +2198,12 @@ impl<T> [T] {
/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
///
/// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
///
/// [`sort_by_key`]: #method.sort_by_key
/// [`binary_search`]: #method.binary_search
/// [`binary_search_by`]: #method.binary_search_by
/// [`partition_point`]: #method.partition_point
///
/// # Examples
///
Expand Down Expand Up @@ -3399,19 +3416,23 @@ impl<T> [T] {
/// If this slice is not partitioned, the returned result is unspecified and meaningless,
/// as this method performs a kind of binary search.
///
/// See also [`binary_search`], [`binary_search_by`], and [`binary_search_by_key`].
///
/// [`binary_search`]: #method.binary_search
/// [`binary_search_by`]: #method.binary_search_by
/// [`binary_search_by_key`]: #method.binary_search_by_key
///
/// # Examples
///
/// ```
/// #![feature(partition_point)]
///
/// let v = [1, 2, 3, 3, 5, 6, 7];
/// let i = v.partition_point(|&x| x < 5);
///
/// assert_eq!(i, 4);
/// assert!(v[..i].iter().all(|&x| x < 5));
/// assert!(v[i..].iter().all(|&x| !(x < 5)));
/// ```
#[unstable(feature = "partition_point", reason = "new API", issue = "73831")]
#[stable(feature = "partition_point", since = "1.52.0")]
pub fn partition_point<P>(&self, mut pred: P) -> usize
where
P: FnMut(&T) -> bool,
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#![feature(option_result_unwrap_unchecked)]
#![feature(option_unwrap_none)]
#![feature(peekable_peek_mut)]
#![feature(partition_point)]
#![feature(once_cell)]
#![feature(unsafe_block_in_unsafe_fn)]
#![feature(int_bits_const)]
Expand Down

0 comments on commit 8280abc

Please sign in to comment.