Added sensible @discardableResult attributes for ConstraintMaker public functions

This commit is contained in:
Alex Pawlowski 2016-06-28 15:55:23 +03:00
parent d00444d7d1
commit b916d75956
3 changed files with 12 additions and 0 deletions

View File

@ -30,20 +30,24 @@
public class ConstraintMakerEditable: ConstraintMakerPriortizable { public class ConstraintMakerEditable: ConstraintMakerPriortizable {
@discardableResult
public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
self.description.multiplier = amount self.description.multiplier = amount
return self return self
} }
@discardableResult
public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue) return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue)
} }
@discardableResult
public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable { public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
self.description.constant = amount self.description.constant = amount
return self return self
} }
@discardableResult
public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable { public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
let insets: ConstraintInsets let insets: ConstraintInsets

View File

@ -30,19 +30,23 @@
public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
@discardableResult
public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
self.description.priority = amount self.description.priority = amount
return self return self
} }
@discardableResult
public func priorityRequired() -> ConstraintMakerFinalizable { public func priorityRequired() -> ConstraintMakerFinalizable {
return self.priority(1000) return self.priority(1000)
} }
@discardableResult
public func priorityHigh() -> ConstraintMakerFinalizable { public func priorityHigh() -> ConstraintMakerFinalizable {
return self.priority(750) return self.priority(750)
} }
@discardableResult
public func priorityMedium() -> ConstraintMakerFinalizable { public func priorityMedium() -> ConstraintMakerFinalizable {
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
return self.priority(500) return self.priority(500)
@ -51,6 +55,7 @@ public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
#endif #endif
} }
@discardableResult
public func priorityLow() -> ConstraintMakerFinalizable { public func priorityLow() -> ConstraintMakerFinalizable {
return self.priority(250) return self.priority(250)
} }

View File

@ -67,14 +67,17 @@ public class ConstraintMakerRelatable {
return editable return editable
} }
@discardableResult
public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
return self.relatedTo(other, relation: .equal, file: file, line: line) return self.relatedTo(other, relation: .equal, file: file, line: line)
} }
@discardableResult
public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable { public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line) return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
} }
@discardableResult
public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line) return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
} }