Skip to content

Commit 26b24d0

Browse files
committed
stdlib: ranges: add @warn_unused_result and propagate documentation from other places
1 parent 14bb1eb commit 26b24d0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stdlib/public/core/Range.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public protocol RangeProtocol : Equatable {
6161
/// `lowerBound < x < upperBound`. `RangeProtocol` makes no requirement as
6262
/// to whether individual range types must contain either their lower or
6363
/// upper bound.
64+
@warn_unused_result
6465
func contains(_ value: Bound) -> Bool
6566

6667
/// Returns `true` iff `self` and `other` contain a value in common.
@@ -105,6 +106,12 @@ extension RangeProtocol {
105106
}
106107

107108
/// Returns `true` iff `self` and `other` contain a value in common.
109+
///
110+
/// Any type of range contains every value `x` where
111+
/// `lowerBound < x < upperBound`. `RangeProtocol` makes no requirement as
112+
/// to whether individual range types must contain either their lower or
113+
/// upper bound.
114+
@warn_unused_result
108115
@inline(__always)
109116
public func overlaps<
110117
Other : RangeProtocol where Other.Bound == Bound
@@ -117,6 +124,7 @@ extension RangeProtocol {
117124
///
118125
/// The bounds of the result, even if it is empty, are always
119126
/// limited to the bounds of `limits`.
127+
@warn_unused_result
120128
@inline(__always)
121129
public func clamped(to limits: Self) -> Self {
122130
return Self(
@@ -359,6 +367,7 @@ extension RangeProtocol {
359367
/// Return true if this is not a closed range type.
360368
///
361369
/// - parameter x: any arbitrary value of type `Bound`.
370+
@warn_unused_result
362371
internal static func _isNotClosed(_ x: Bound) -> Bool {
363372
return Self(uncheckedBounds: (lower: x, upper: x)).isEmpty
364373
}
@@ -640,7 +649,7 @@ public func ..< <
640649
}
641650

642651
@warn_unused_result
643-
public func ~= <R: RangeProtocol> (
652+
public func ~= <R : RangeProtocol> (
644653
pattern: R, value: R.Bound
645654
) -> Bool {
646655
return pattern.contains(value)

0 commit comments

Comments
 (0)