Browse Source

Add extra protocol conformances to ConstraintPriority

Robert Payne 9 years ago
parent
commit
681dfcbc3a
1 changed files with 15 additions and 3 deletions
  1. 15 3
      Source/ConstraintPriority.swift

+ 15 - 3
Source/ConstraintPriority.swift

@@ -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
+    }
 }