Add extra protocol conformances to ConstraintPriority

This commit is contained in:
Robert Payne 2017-02-11 22:59:05 +13:00
parent a15821b791
commit 681dfcbc3a
1 changed files with 15 additions and 3 deletions

View File

@ -28,12 +28,12 @@
#endif
public struct ConstraintPriority : ExpressibleByFloatLiteral {
public struct ConstraintPriority : ExpressibleByFloatLiteral, Strideable, Equatable {
public typealias FloatLiteralType = Float
public let value: FloatLiteralType
public let value: Float
public init(floatLiteral value: FloatLiteralType) {
public init(floatLiteral value: Float) {
self.value = value
}
@ -61,4 +61,16 @@ public struct ConstraintPriority : ExpressibleByFloatLiteral {
public static var low: ConstraintPriority {
return 250.0
}
public func advanced(by n: Float) -> ConstraintPriority {
return ConstraintPriority(self.value + n)
}
public func distance(to other: ConstraintPriority) -> Float {
return other.value - self.value
}
public static func ==(lhs: ConstraintPriority, rhs: ConstraintPriority) -> Bool {
return lhs.value == rhs.value
}
}