yattee/Extensions/Comparable+Clamped.swift
Arkadiusz Fal 01f58b6458 Hello, mpv! 🎉
2022-08-15 16:33:54 +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)
}
}