File tree 1 file changed +6
-4
lines changed
StandardLibrary/Sources/Core
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -21,14 +21,16 @@ public type Range<Bound: SemiRegular> {
21
21
&self.upper_bound = upper_bound
22
22
}
23
23
24
- /// Returns `true` iff `element` is contained in `self`.
25
- public fun contains<B: Comparable where Bound == B>(_ element: B) -> Bool {
26
- ((element as! Bound) >= lower_bound) && ((element as! Bound) < upper_bound)
24
+ /// Returns `true` iff `x` is contained in `self`.
25
+ public fun contains<B: Comparable where Bound == B>(_ x: B) -> Bool {
26
+ let e = Pointer<Bound>(type_punning: pointer[to: x])
27
+ return (e.unsafe[] >= lower_bound) && (e.unsafe[] < upper_bound)
27
28
}
28
29
29
30
/// Returns `true` iff `other` is contained in `self`.
30
31
public fun contains<B: Comparable where Bound == B>(_ other: Range<B>) -> Bool {
31
- ((other.lower_bound as! Bound) >= self.lower_bound) && ((other.upper_bound as! Bound) <= self.upper_bound)
32
+ let e = Pointer<Self>(type_punning: pointer[to: other])
33
+ return (e.unsafe[].lower_bound >= self.lower_bound) && (e.unsafe[].upper_bound <= self.upper_bound)
32
34
}
33
35
34
36
}
You can’t perform that action at this time.
0 commit comments