 //===--- Stable Partition -------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
-extension Collection
-where Self : MutableCollectionAlgorithms {
-
+extension MutableCollectionAlgorithms {
+  /// Moves all elements satisfying `isSuffixElement` into a suffix of the
+  /// collection, preserving their relative order, and returns the start of the
+  /// resulting suffix.
+  ///
+  /// - Complexity: O(n) where n is the number of elements.
   @discardableResult
   mutating func stablePartition(
     isSuffixElement: (Element) throws -> Bool
   ) rethrows -> Index {
-        return try stablePartition(
-            count: count, isSuffixElement: isSuffixElement)
-  }
-
-    /// Moves all elements satisfying `isSuffixElement` into a suffix of the collection,
-    /// preserving their relative order, returning the start of the resulting suffix.
-    ///
-    /// - Complexity: O(n) where n is the number of elements.
-    /// - Precondition: `n == self.count`
-    fileprivate mutating func stablePartition(
-        count n: Int, isSuffixElement: (Element) throws-> Bool
-    ) rethrows -> Index {
-        if n == 0 { return startIndex }
-        if n == 1 {
-            return try isSuffixElement(self[startIndex]) ? startIndex : endIndex
-        }
-        let h = n / 2, i = index(startIndex, offsetBy: h)
-        let j = try self[..<i].stablePartition(
-            count: h, isSuffixElement: isSuffixElement)
-        let k = try self[i...].stablePartition(
-            count: n - h, isSuffixElement: isSuffixElement)
-        return self[j..<k].rotate(shiftingToStart: i)
-    }
+    return try stablePartition(count: count, isSuffixElement: isSuffixElement)
+  }
+
+  /// Moves all elements satisfying `isSuffixElement` into a suffix of the
+  /// collection, preserving their relative order, and returns the start of the
+  /// resulting suffix.
+  ///
+  /// - Complexity: O(n) where n is the number of elements.
+  /// - Precondition: `n == self.count`
+  fileprivate mutating func stablePartition(
+    count n: Int, isSuffixElement: (Element) throws-> Bool
+  ) rethrows -> Index {
+    if n == 0 { return startIndex }
+    if n == 1 {
+      return try isSuffixElement(self[startIndex]) ? startIndex : endIndex
+    }
+    let h = n / 2, i = index(startIndex, offsetBy: h)
+    let j = try self[..<i].stablePartition(
+      count: h, isSuffixElement: isSuffixElement)
+    let k = try self[i...].stablePartition(
+      count: n - h, isSuffixElement: isSuffixElement)
+    return self[j..<k].rotate(shiftingToStart: i)
+  }
 }
 
 extension Collection {
-    func stablyPartitioned(
-        isSuffixElement p: (Element) -> Bool
-    ) -> [Element] {
-        var a = Array(self)
-        a.stablePartition(isSuffixElement: p)
-        return a
-    }
+  func stablyPartitioned(
+    isSuffixElement p: (Element) -> Bool
+  ) -> [Element] {
+    var a = Array(self)
+    a.stablePartition(isSuffixElement: p)
+    return a
+  }
 }
 
 extension LazyCollectionProtocol
 where Element == Elements.Element {
-    func stablyPartitioned(
-        isSuffixElement p: (Element) -> Bool
-    ) -> LazyCollection<[Element]> {
-        return elements.stablyPartitioned(isSuffixElement: p).lazy
-    }
+  func stablyPartitioned(
+    isSuffixElement p: (Element) -> Bool
+  ) -> LazyCollection<[Element]> {
+    return elements.stablyPartitioned(isSuffixElement: p).lazy
+  }
 }
 
 extension Collection {

  }
}

//===--- Tests ------------------------------------------------------------===//
//===----------------------------------------------------------------------===//

func address<T>(_ p: UnsafePointer<T>) -> UInt { return UInt(bitPattern: p )}


// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-build-swift -g -Onone -DUSE_STDLIBUNITTEST %s -o %t/Algorithms
// RUN: %target-run %t/Algorithms
// REQUIRES: executable_test

#if USE_STDLIBUNITTEST
import Swift
import StdlibUnittest
#endif

//===--- Rotate -----------------------------------------------------------===//
//===----------------------------------------------------------------------===//

/// Provides customization points for `MutableCollection` algorithms.
///
/// If incorporated into the standard library, these requirements would just be
/// part of `MutableCollection`.  In the meantime, you can declare conformance
/// of a collection to `MutableCollectionAlgorithms` to get these customization
/// points to be used from other algorithms defined on
/// `MutableCollectionAlgorithms`.
public protocol MutableCollectionAlgorithms : MutableCollection
  where SubSequence : MutableCollectionAlgorithms
{
  /// Rotates the elements of the collection so that the element
