Skip to content

Commit

Permalink
Switch to standard library preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
natecook1000 committed Feb 10, 2020
1 parent b60223b commit 5321c34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stdlib/public/core/RangeSetStorage.swift
Expand Up @@ -37,7 +37,8 @@ struct _RangeSetStorage<T: Comparable> {
}

func unsafeRange(low: Int32, high: Int) -> Range<T> {
unsafeBitCast(Int(low)..<high, to: Range<T>.self)
_precondition(T.self == Int.self)
return unsafeBitCast(Int(low)..<high, to: Range<T>.self)
}
}

Expand Down Expand Up @@ -97,7 +98,7 @@ extension _RangeSetStorage: RandomAccessCollection, MutableCollection {
switch _storage {
case .empty: fatalError("Can't access elements of empty storage")
case let .singleRange(high, low):
assert(T.self == Int.self)
_precondition(T.self == Int.self)
return unsafeRange(low: low, high: high)
case let .variadic(ranges):
return ranges[i]
Expand All @@ -107,7 +108,7 @@ extension _RangeSetStorage: RandomAccessCollection, MutableCollection {
switch _storage {
case .empty: fatalError("Can't access elements of empty storage")
case .singleRange:
assert(T.self == Int.self)
_precondition(T.self == Int.self)
let intRange = newValue as! Range<Int>
if let lowerBound = Int32(exactly: intRange.lowerBound) {
_storage = .singleRange(high: intRange.upperBound, low: lowerBound)
Expand Down

0 comments on commit 5321c34

Please sign in to comment.