1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-10 19:40:33 +05:30
yattee/Extensions/Comparable+Clamped.swift
Arkadiusz Fal 717830ee99 Hello, mpv! 🎉
2022-05-27 23:05:07 +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)
}
}