yattee/Extensions/Comparable+Clamped.swift
Arkadiusz Fal 31a28a7cbd Hello, mpv! 🎉
2022-10-27 18:03:57 +02:00

8 lines
168 B
Swift

import Foundation
extension Comparable {
func clamped(to limits: ClosedRange<Self>) -> Self {
min(max(self, limits.lowerBound), limits.upperBound)
}
}