1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Extensions/Comparable+Clamped.swift

8 lines
168 B
Swift
Raw Normal View History

2022-02-17 01:53:11 +05:30
import Foundation
extension Comparable {
func clamped(to limits: ClosedRange<Self>) -> Self {
min(max(self, limits.lowerBound), limits.upperBound)
}
}