Created
December 17, 2016 21:41
-
-
Save MrMage/74c7920af49ad82ba7fb5549a24047a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct NonemptySequence<Element> { | |
fileprivate let _storage: [Element] | |
public init(first: Element, rest: [Element]) { | |
_storage = [first] + rest | |
} | |
} | |
extension NonemptySequence: Sequence { | |
// call through to _storage here | |
} | |
extension NonemptySequence where Element: Equatable { | |
public static func ==(A: NonemptySequence, B: NonemptySequence) -> Bool { | |
return A._storage == B._storage | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment