File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import Foundation
1717/// - max: The highest possible returned value
1818///
1919/// - Returns: `value`, clamped to be between `min` (inclusive) and `max` (inclusive)
20+ @inline ( __always)
2021public func clamp < Value: Comparable > ( min: Value , value: Value , max: Value ) -> Value {
2122 Swift . max ( min, Swift . min ( value, max) )
2223}
@@ -32,6 +33,7 @@ public extension Comparable {
3233 /// - max: The highest possible returned value
3334 ///
3435 /// - Returns: this value, clamped to be between `min` (inclusive) and `max` (inclusive)
36+ @inline ( __always)
3537 func clamped( min: Self , max: Self ) -> Self {
3638 clamp ( min: min, value: self , max: max)
3739 }
@@ -42,6 +44,7 @@ public extension Comparable {
4244 /// - Parameter range: The range of possible values to be returned
4345 ///
4446 /// - Returns: this value, clamped to be between `range.lowerBound` (inclusive) and `range.upperBound` (inclusive)
47+ @inline ( __always)
4548 func clamped( within range: ClosedRange < Self > ) -> Self {
4649 clamped ( min: range. lowerBound, max: range. upperBound)
4750 }
You can’t perform that action at this time.
0 commit comments