1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-09 19:10:32 +05:30
yattee/Extensions/Comparable+Clamped.swift
Arkadiusz Fal d6d5def4e7 Hello, mpv! 🎉
2022-03-27 22:02:30 +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)
}
}