@@ -3689,18 +3689,22 @@ impl<T> [T] {
36893689 self . partition_dedup_by ( |a, b| a == b)
36903690 }
36913691
3692- /// Moves all but the first of consecutive elements to the end of the slice satisfying
3693- /// a given equality relation .
3692+ /// Moves all but the first of consecutive elements to the end of the slice that are
3693+ /// "equal" according to the given predicate function .
36943694 ///
36953695 /// Returns two slices. The first contains no consecutive repeated elements.
36963696 /// The second contains all the duplicates in no specified order.
36973697 ///
3698- /// The `same_bucket` function is passed references to two elements from the slice and
3699- /// must determine if the elements compare equal. The elements are passed in opposite order
3700- /// from their order in the slice, so if `same_bucket(a, b)` returns `true`, `a` is moved
3701- /// at the end of the slice .
3698+ /// The predicate `same_bucket(p, x)` is passed references to two elements from
3699+ /// the slice and must determine if the elements compare equal. The element `p` occurs
3700+ /// *before* `x` in the slice (`[.., p, .., x, ..]`), so `same_bucket(x, p)`
3701+ /// is receiving them in reversed order .
37023702 ///
3703- /// If the slice is sorted, the first returned slice contains no duplicates.
3703+ /// If the slice is sorted, the first returned slice contains no duplicates. For more
3704+ /// complicated predicates however, the order (ascending vs. descending) can matter.
3705+ ///
3706+ /// Both references passed to `same_bucket` are mutable.
3707+ /// This allows merged elements in the first slice by mutating `p` and returning `true`.
37043708 ///
37053709 /// # Examples
37063710 ///
@@ -3709,7 +3713,7 @@ impl<T> [T] {
37093713 ///
37103714 /// let mut slice = ["foo", "Foo", "BAZ", "Bar", "bar", "baz", "BAZ"];
37113715 ///
3712- /// let (dedup, duplicates) = slice.partition_dedup_by(|a, b| a .eq_ignore_ascii_case(b ));
3716+ /// let (dedup, duplicates) = slice.partition_dedup_by(|x, p| x .eq_ignore_ascii_case(p ));
37133717 ///
37143718 /// assert_eq!(dedup, ["foo", "BAZ", "Bar", "baz"]);
37153719 /// assert_eq!(duplicates, ["bar", "Foo", "BAZ"]);
@@ -3790,7 +3794,7 @@ impl<T> [T] {
37903794 // are less than `len`, thus are inside `self`. `prev_ptr_write` points to
37913795 // one element before `ptr_write`, but `next_write` starts at 1, so
37923796 // `prev_ptr_write` is never less than 0 and is inside the slice.
3793- // This fulfils the requirements for dereferencing `ptr_read`, `prev_ptr_write`
3797+ // This fulfills the requirements for dereferencing `ptr_read`, `prev_ptr_write`
37943798 // and `ptr_write`, and for using `ptr.add(next_read)`, `ptr.add(next_write - 1)`
37953799 // and `prev_ptr_write.offset(1)`.
37963800 //
0 commit comments