     func count(where predicate: (Element) throws -> Bool) rethrows -> Int {
         
         var count = 0
-        for element in self where try predicate(element) {
+        for element in self {
+            guard try predicate(element) else { continue }
+            
             count += 1
         }
         return count

}


public extension Collection {

    /// Return the element at the specified index only if it is within bounds, otherwise nil.
    subscript(safe index: Index) -> Element? {
        
        return self.indices.contains(index) ? self[index] : nil
    }
    
}


extension Sequence where Element: Equatable {


extension RangeReplaceableCollection where Element: Equatable {
    
    /// Remove first collection element that is equal to the given `element`.
    ///
    /// - Parameter element: The element to be removed.
    mutating func remove(_ element: Element) {
        
        if let index = self.index(of: element) {
