Add inline documentation for Decoded/Alternative

This commit is contained in:
Gordon Fontenot
2016-04-02 18:58:52 -05:00
parent 5f9312b4d3
commit 7602bf206f

View File

@@ -1,22 +1,35 @@
/**
return the left `Decoded` value if it is `.Success`, otherwise return the right side
infix operator <|> { associativity left precedence 140 }
- If the left hand side is successful, this will return the left hand side
- If the left hand side is unsuccesful, this will return the right hand side
/**
Return the left `Decoded` value if it is `.Success`, otherwise return the
default value on the right.
- If the left hand side is `.Success`, this will return the argument on the
left hand side.
- If the left hand side is `.Failure`, this will return the argument on the
right hand side.
- parameter lhs: A value of type `Decoded<T>`
- parameter rhs: A value of type `Decoded<T>`
- returns: A value of type `Decoded<T>`
*/
infix operator <|> { associativity left precedence 140 }
public func <|> <T>(lhs: Decoded<T>, @autoclosure rhs: () -> Decoded<T>) -> Decoded<T> {
return lhs.or(rhs)
}
public extension Decoded {
/**
Return `self` if it is `.Success`, otherwise return the provided default
value.
- If `self` is `.Success`, this will return `self`.
- If `self` is `.Failure`, this will return the default.
- parameter other: A value of type `Decoded<T>`
- returns: A value of type `Decoded<T>`
*/
func or(@autoclosure other: () -> Decoded<T>) -> Decoded<T> {
switch self {
case .Success: return self