Fixed Failable<Sequence>: Sequence conformance for Swift 5 updates
This commit is contained in:
parent
b9658cdb93
commit
f19f88f3bd
|
@ -27,10 +27,10 @@ extension Failable {
|
||||||
|
|
||||||
/// See [`Optional.??(_:_:)`](https://developer.apple.com/documentation/swift/1539917).
|
/// See [`Optional.??(_:_:)`](https://developer.apple.com/documentation/swift/1539917).
|
||||||
public func ?? <T, V>(optional: Failable<T?, V>, defaultValue: @autoclosure () throws -> T) rethrows -> T {
|
public func ?? <T, V>(optional: Failable<T?, V>, defaultValue: @autoclosure () throws -> T) rethrows -> T {
|
||||||
return try optional.value ?? defaultValue
|
return try optional.value ?? defaultValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Optional.??(_:_:)`](https://developer.apple.com/documentation/swift/1541015).
|
/// See [`Optional.??(_:_:)`](https://developer.apple.com/documentation/swift/1541015).
|
||||||
public func ?? <T, V>(optional: Failable<T?, V>, defaultValue: @autoclosure () throws -> T?) rethrows -> T? {
|
public func ?? <T, V>(optional: Failable<T?, V>, defaultValue: @autoclosure () throws -> T?) rethrows -> T? {
|
||||||
return try optional.value ?? defaultValue
|
return try optional.value ?? defaultValue()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
extension Failable: Sequence where T: Sequence {
|
extension Failable: Sequence where T: Sequence {
|
||||||
|
|
||||||
/// See [`Sequence.Element`](https://developer.apple.com/documentation/swift/sequence/2908099-element).
|
/// See [`Sequence.Element`](https://developer.apple.com/documentation/swift/sequence/2908099-element).
|
||||||
public typealias Element = T.Element
|
public typealias Element = T.Element
|
||||||
|
|
||||||
|
@ -13,38 +12,38 @@ extension Failable: Sequence where T: Sequence {
|
||||||
|
|
||||||
/// See [`Sequence.split(separator:maxSplits:omittingEmptySubsequences:)`](https://developer.apple.com/documentation/swift/sequence/2908109-split).
|
/// See [`Sequence.split(separator:maxSplits:omittingEmptySubsequences:)`](https://developer.apple.com/documentation/swift/sequence/2908109-split).
|
||||||
public func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator isSeparator: (T.Element) throws -> Bool) rethrows
|
public func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator isSeparator: (T.Element) throws -> Bool) rethrows
|
||||||
-> [T.SubSequence]
|
-> [ArraySlice<T.Element>]
|
||||||
{
|
{
|
||||||
return try self.value.split(maxSplits: maxSplits, omittingEmptySubsequences: omittingEmptySubsequences, whereSeparator: isSeparator)
|
return try self.value.split(maxSplits: maxSplits, omittingEmptySubsequences: omittingEmptySubsequences, whereSeparator: isSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.suffix(_:)`](https://developer.apple.com/documentation/swift/sequence/2965540-suffix).
|
/// See [`Sequence.suffix(_:)`](https://developer.apple.com/documentation/swift/sequence/2965540-suffix).
|
||||||
public func suffix(_ maxLength: Int) -> T.SubSequence {
|
public func suffix(_ maxLength: Int) -> [T.Element] {
|
||||||
return self.value.suffix(maxLength)
|
return self.value.suffix(maxLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.prefix(while:)`](https://developer.apple.com/documentation/swift/sequence/2965528-prefix)
|
/// See [`Sequence.prefix(while:)`](https://developer.apple.com/documentation/swift/sequence/2965528-prefix)
|
||||||
public func prefix(while predicate: (T.Element) throws -> Bool) rethrows -> T.SubSequence {
|
public func prefix(while predicate: (T.Element) throws -> Bool) rethrows -> [T.Element] {
|
||||||
return try self.value.prefix(while: predicate)
|
return try self.value.prefix(while: predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.prefix(_:)`](https://developer.apple.com/documentation/swift/sequence/2965524-prefix).
|
/// See [`Sequence.prefix(_:)`](https://developer.apple.com/documentation/swift/sequence/2965524-prefix).
|
||||||
public func prefix(_ maxLength: Int) -> T.SubSequence {
|
public func prefix(_ maxLength: Int) -> PrefixSequence<T> {
|
||||||
return self.value.prefix(maxLength)
|
return self.value.prefix(maxLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.drop(while:)`](https://developer.apple.com/documentation/swift/sequence/2965501-drop).
|
/// See [`Sequence.drop(while:)`](https://developer.apple.com/documentation/swift/sequence/2965501-drop).
|
||||||
public func drop(while predicate: (T.Element) throws -> Bool) rethrows -> T.SubSequence {
|
public func drop(while predicate: (T.Element) throws -> Bool) rethrows -> DropWhileSequence<T> {
|
||||||
return try self.value.drop(while: predicate)
|
return try self.value.drop(while: predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.dropLast`](https://developer.apple.com/documentation/swift/sequence/2965508-droplast).
|
/// See [`Sequence.dropLast`](https://developer.apple.com/documentation/swift/sequence/2965508-droplast).
|
||||||
public func dropLast(_ k: Int) -> T.SubSequence {
|
public func dropLast(_ k: Int) -> [T.Element] {
|
||||||
return self.value.dropLast(k)
|
return self.value.dropLast(k)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`Sequence.dropFirst(_:)`](https://developer.apple.com/documentation/swift/sequence/2965504-dropfirst).
|
/// See [`Sequence.dropFirst(_:)`](https://developer.apple.com/documentation/swift/sequence/2965504-dropfirst).
|
||||||
public func dropFirst(_ k: Int) -> T.SubSequence {
|
public func dropFirst(_ k: Int) -> DropFirstSequence<T> {
|
||||||
return self.value.dropFirst(k)
|
return self.value.dropFirst(k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue