Skip to content

Commit e4a700c

Browse files
committed
Update inline documentation.
1 parent 85df179 commit e4a700c

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

stdlib/public/core/Result.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public enum Result<Success, Failure: Error> {
2020
/// A failure, storing a `Failure` value.
2121
case failure(Failure)
2222

23-
/// Evaluates the given transform closure when this `Result` instance is
24-
/// `.success`, passing the value as a parameter.
23+
/// Evaluates the given closure when this `Result` instance is `.success`,
24+
/// passing the success value as a parameter.
2525
///
2626
/// Use the `map` method with a closure that returns a non-`Result` value.
2727
///
28-
/// - Parameter transform: A closure that takes the successful value of the
28+
/// - Parameter transform: A closure that takes the success value of the
2929
/// instance.
30-
/// - Returns: A new `Result` instance with the result of the transform, if
31-
/// it was applied.
30+
/// - Returns: A `Result` instance with the result of evaluating the given
31+
/// closure as the new success value if this instance is `.success`.
3232
public func map<NewSuccess>(
3333
_ transform: (Success) -> NewSuccess
3434
) -> Result<NewSuccess, Failure> {
@@ -40,16 +40,16 @@ public enum Result<Success, Failure: Error> {
4040
}
4141
}
4242

43-
/// Evaluates the given transform closure when this `Result` instance is
44-
/// `.failure`, passing the error as a parameter.
43+
/// Evaluates the given closure when this `Result` instance is `.failure`,
44+
/// passing the failure value as a parameter.
4545
///
4646
/// Use the `mapError` method with a closure that returns a non-`Result`
4747
/// value.
4848
///
4949
/// - Parameter transform: A closure that takes the failure value of the
5050
/// instance.
51-
/// - Returns: A new `Result` instance with the result of the transform, if
52-
/// it was applied.
51+
/// - Returns: A `Result` instance with the result of evaluating the given
52+
/// closure as the new failure value if this instance is `.failure`.
5353
public func mapError<NewFailure>(
5454
_ transform: (Failure) -> NewFailure
5555
) -> Result<Success, NewFailure> {
@@ -61,13 +61,13 @@ public enum Result<Success, Failure: Error> {
6161
}
6262
}
6363

64-
/// Evaluates the given transform closure when this `Result` instance is
65-
/// `.success`, passing the value as a parameter and flattening the result.
64+
/// Evaluates the given closure when this `Result` instance is `.success`,
65+
/// passing the success value as a parameter.
6666
///
67-
/// - Parameter transform: A closure that takes the successful value of the
67+
/// - Parameter transform: A closure that takes the success value of the
6868
/// instance.
69-
/// - Returns: A new `Result` instance, either from the transform or from
70-
/// the previous error value.
69+
/// - Returns: A`Result` instance, either from the closure or the previous
70+
/// `.failure`.
7171
public func flatMap<NewSuccess>(
7272
_ transform: (Success) -> Result<NewSuccess, Failure>
7373
) -> Result<NewSuccess, Failure> {
@@ -79,13 +79,13 @@ public enum Result<Success, Failure: Error> {
7979
}
8080
}
8181

82-
/// Evaluates the given transform closure when this `Result` instance is
83-
/// `.failure`, passing the error as a parameter and flattening the result.
82+
/// Evaluates the given closure when this `Result` instance is `.failure`,
83+
/// passing the failure value as a parameter.
8484
///
85-
/// - Parameter transform: A closure that takes the error value of the
85+
/// - Parameter transform: A closure that takes the failure value of the
8686
/// instance.
87-
/// - Returns: A new `Result` instance, either from the transform or from
88-
/// the previous success value.
87+
/// - Returns: A `Result` instance, either from the closure or the previous
88+
/// `.success`.
8989
public func flatMapError<NewFailure>(
9090
_ transform: (Failure) -> Result<Success, NewFailure>
9191
) -> Result<Success, NewFailure> {
@@ -97,10 +97,10 @@ public enum Result<Success, Failure: Error> {
9797
}
9898
}
9999

100-
/// Attempts to get the `success` value as a throwing expression.
100+
/// Get the success value as a throwing expression.
101101
///
102-
/// - Returns: The success value, if the instance is a success.
103-
/// - Throws: The failure value, if the instance is a failure.
102+
/// - Returns: The success value, if the instance is `.success`.
103+
/// - Throws: The failure value, if the instance is `.failure`.
104104
public func get() throws -> Success {
105105
switch self {
106106
case let .success(success):
@@ -112,20 +112,20 @@ public enum Result<Success, Failure: Error> {
112112
}
113113

114114
extension Result where Failure == Swift.Error {
115-
/// Create an instance by capturing the output of a throwing closure.
115+
/// Create an instance by evaluating a throwing closure, capturing the
116+
/// returned value as a `.success` or any thrown error as `.failure`.
116117
///
117118
/// - Parameter catching: A throwing closure to evaluate.
118119
@_transparent
119120
public init(catching body: () throws -> Success) {
120121
do {
121-
let value = try body()
122-
self = .success(value)
122+
self = .success(try body())
123123
} catch {
124124
self = .failure(error)
125125
}
126126
}
127127
}
128128

129-
extension Result : Equatable where Success : Equatable, Failure : Equatable { }
129+
extension Result: Equatable where Success: Equatable, Failure: Equatable { }
130130

131-
extension Result : Hashable where Success : Hashable, Failure : Hashable { }
131+
extension Result: Hashable where Success: Hashable, Failure: Hashable { }

0 commit comments

Comments
 (0)