File tree Expand file tree Collapse file tree 2 files changed +11
-29
lines changed Expand file tree Collapse file tree 2 files changed +11
-29
lines changed Original file line number Diff line number Diff line change 2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2018 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -128,15 +128,4 @@ extension Result where Error == Swift.Error {
128
128
129
129
extension Result : Equatable where Value : Equatable , Error : Equatable { }
130
130
131
- extension Result : Hashable where Value : Hashable , Error : Hashable {
132
- public func hash( into hasher: inout Hasher ) {
133
- switch self {
134
- case let . value( value) :
135
- hasher. combine ( value)
136
- hasher. combine ( Optional< Error> . none)
137
- case let . error( error) :
138
- hasher. combine ( Optional< Value> . none)
139
- hasher. combine ( error)
140
- }
141
- }
142
- }
131
+ extension Result : Hashable where Value : Hashable , Error : Hashable { }
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ fileprivate extension Result {
21
21
case . error:
22
22
return nil
23
23
}
24
-
25
- var error : Error ? {
26
- switch self {
27
- case . value :
28
- return nil
29
- case let . error ( error ) :
30
- return error
31
- }
24
+ }
25
+
26
+ var error : Error ? {
27
+ switch self {
28
+ case . value :
29
+ return nil
30
+ case let . error( error ) :
31
+ return error
32
32
}
33
33
}
34
34
}
@@ -71,14 +71,7 @@ ResultTests.test("Throwing Initialization and Unwrapping") {
71
71
let result1 = Result { try throwing ( ) }
72
72
let result2 = Result { try notThrowing ( ) }
73
73
74
- // Kept getting enum case 'error' cannot be used as an instance member, so get value manually.
75
- switch result1 {
76
- case let . error( error) :
77
- expectEqual ( error as? Err , Err . err)
78
- case . value:
79
- expectUnreachable ( )
80
- }
81
-
74
+ expectEqual ( result1. error as? Err , Err . err)
82
75
expectEqual ( result2. value, string)
83
76
84
77
do {
You can’t perform that action at this time.
0 commit comments