Added range operators to Failable<Comparable, T> type

This commit is contained in:
Caleb Kleveter 2018-11-30 07:45:34 -06:00
parent 847c7eabea
commit f25f2abf10
No known key found for this signature in database
GPG Key ID: B38DBD5CF2C98D69
1 changed files with 14 additions and 0 deletions

View File

@ -38,6 +38,20 @@ extension Failable: Comparable where T: Comparable {
} }
} }
/// See [`Comparable....(_:_:)`](https://developer.apple.com/documentation/swift/comparable/2949800).
public func ... <T, V1, V2>(lhs: Failable<T, V1>, rhs: Failable<T, V2>)throws
-> Failable<ClosedRange<T>, ElementValidation<ClosedRange<T>, AppendedValidations<T, V1, V2>>> where T: Comparable
{
return try Failable(lhs.value...rhs.value)
}
/// See [`Comparable...<(_:_:)`](https://developer.apple.com/documentation/swift/comparable/2949700).
public func ..< <T, V1, V2>(lhs: Failable<T, V1>, rhs: Failable<T, V2>)throws
-> Failable<Range<T>, ElementValidation<Range<T>, AppendedValidations<T, V1, V2>>> where T: Comparable
{
return try Failable(lhs.value..<rhs.value)
}
/// Checks that the `value` property from one `Failable` instance is great than another, where type `T` is the same and comforms to `Comparable`, /// Checks that the `value` property from one `Failable` instance is great than another, where type `T` is the same and comforms to `Comparable`,
/// but the `Validations` are different. /// but the `Validations` are different.
/// ///