[swift-evolution] Add clamp(value: Bound) -> Bound to ClosedInterval
kevin at sb.org
Wed Feb 17 17:51:08 CST 2016
I'd like to see ClosedInterval gain a new method
/// Returns `value` clamped to `self`.
func clamp(value: Bound) -> Bound
This can't go on HalfOpenInterval (and therefore can't go on IntervalType) because a half-open interval doesn't have a known largest-contained-value (and in fact it can be empty), but it's perfectly reasonable for ClosedInterval to have this.
More information about the swift-evolution