Skip to content

wltrup/CollectionComparable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CollectionComparable

Xcode Swift GitHub tag (latest SemVer) GitHub

What

CollectionComparable is a Swift Package Manager package for iOS/tvOS (10.0 and above), watchOS (4.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, adding a protocol extension to Collection so that it's Comparable when its Element type is Comparable.

/// This isn't sufficient. Concrete types conforming to `Collection` who want to be
/// `Comparable` still need to declare conformance to `Comparable`. That's because
/// `Collection` is a *protocol*, not a concrete type, and protocols can't be extended
/// to add conformances to other protocols, ie, we can't say
///
/// `extension Collection: Comparable where Element: Comparable { ... }`
///
public extension Collection where Element: Comparable {

    static func < (lhs: Self, rhs: Self) -> Bool

}

Installation

CollectionComparable is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.

License

CollectionComparable is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages