mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
add necessary closure for partition_point
This commit is contained in:
parent
c957b809e9
commit
0eb0d891ad
@ -2600,7 +2600,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
|
||||
///
|
||||
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
|
||||
/// let num = 42;
|
||||
/// let idx = deque.partition_point(&num);
|
||||
/// let idx = deque.partition_point(|&x| x < num);
|
||||
/// // The above is equivalent to `let idx = deque.binary_search(&num).unwrap_or_else(|x| x);`
|
||||
/// deque.insert(idx, num);
|
||||
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
|
||||
@ -2754,7 +2754,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
|
||||
///
|
||||
/// let mut deque: VecDeque<_> = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].into();
|
||||
/// let num = 42;
|
||||
/// let idx = deque.partition_point(&num);
|
||||
/// let idx = deque.partition_point(|&x| x < num);
|
||||
/// deque.insert(idx, num);
|
||||
/// assert_eq!(deque, &[0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
|
||||
/// ```
|
||||
|
@ -2337,7 +2337,7 @@ impl<T> [T] {
|
||||
/// ```
|
||||
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
|
||||
/// let num = 42;
|
||||
/// let idx = s.partition_point(&num);
|
||||
/// let idx = s.partition_point(|&x| x < num);
|
||||
/// // The above is equivalent to `let idx = s.binary_search(&num).unwrap_or_else(|x| x);`
|
||||
/// s.insert(idx, num);
|
||||
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
|
||||
@ -3752,7 +3752,7 @@ impl<T> [T] {
|
||||
/// ```
|
||||
/// let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
|
||||
/// let num = 42;
|
||||
/// let idx = s.partition_point(&num);
|
||||
/// let idx = s.partition_point(|&x| x < num);
|
||||
/// s.insert(idx, num);
|
||||
/// assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
|
||||
/// ```
|
||||
|
Loading…
Reference in New Issue
Block a user