Skip to content

Commit dc2bd8d

Browse files
gribozavrtkremenek
authored andcommitted
stdlib: add an unavailable ClosedRange.clamp() function (#2908)
1 parent c05eb52 commit dc2bd8d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

stdlib/public/core/Range.swift.gyb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,24 @@ extension Range {
614614
}
615615
}
616616

617+
extension ClosedRange {
618+
@available(*, unavailable, message: "Call clamped(to:) and swap the argument and the receiver. For example, x.clamp(y) becomes y.clamped(to: x) in Swift 3.")
619+
public func clamp(
620+
_ intervalToClamp: ClosedRange<Bound>
621+
) -> ClosedRange<Bound> {
622+
Builtin.unreachable()
623+
}
624+
}
625+
626+
extension CountableClosedRange {
627+
@available(*, unavailable, message: "Call clamped(to:) and swap the argument and the receiver. For example, x.clamp(y) becomes y.clamped(to: x) in Swift 3.")
628+
public func clamp(
629+
_ intervalToClamp: CountableClosedRange<Bound>
630+
) -> CountableClosedRange<Bound> {
631+
Builtin.unreachable()
632+
}
633+
}
634+
617635
@available(*, unavailable, message: "IntervalType has been removed in Swift 3. Use ranges instead.")
618636
public typealias IntervalType = Void
619637

0 commit comments

Comments
 (0)