Skip to content

Commit 7fb5905

Browse files
committed
Updates for review comments.
1 parent 33dcfc4 commit 7fb5905

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

stdlib/public/core/Result.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -128,15 +128,4 @@ extension Result where Error == Swift.Error {
128128

129129
extension Result : Equatable where Value : Equatable, Error : Equatable { }
130130

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 { }

test/stdlib/Result.swift

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ fileprivate extension Result {
2121
case .error:
2222
return nil
2323
}
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
3232
}
3333
}
3434
}
@@ -71,14 +71,7 @@ ResultTests.test("Throwing Initialization and Unwrapping") {
7171
let result1 = Result { try throwing() }
7272
let result2 = Result { try notThrowing() }
7373

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)
8275
expectEqual(result2.value, string)
8376

8477
do {

0 commit comments

Comments
 (0)