Skip to content

Commit 227b2ad

Browse files
committed
Add Never to Equatable and Hashable Swift 5.0
1 parent 3384f70 commit 227b2ad

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Conform Never to Equatable and Hashable Swift 5.0
2+
3+
// Proposal: SE-0215
4+
// Never is very useful for representing impossible code.
5+
// Most people are familiar with it as the return type of
6+
// functions like fatalError, but Never is also useful
7+
// when working with generic classes.
8+
// The standard library should add Equatable and Hashable
9+
// implementations for Never:
10+
11+
extension Never: Equatable {
12+
public static func == (lhs: Never, rhs: Never) -> Bool {
13+
switch (lhs, rhs) {
14+
}
15+
}
16+
}
17+
18+
extension Never: Hashable {
19+
public func hash(into hasher: inout Hasher) {
20+
}
21+
}
Loading

0 commit comments

Comments
 (0)