mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Change unicodescalar to failable
We were using a precondition which crashes the program when invalid input is provided. We want to provide a way to gracefully check and handle invalid input or shutdown the program if necessary. SR-1930
This commit is contained in:
@@ -60,7 +60,7 @@ func nthUnicodeScalar(_ n: UInt32) -> UnicodeScalar {
|
||||
for r in unicodeScalarRanges {
|
||||
count += r.upperBound - r.lowerBound
|
||||
if count > n {
|
||||
return UnicodeScalar(r.upperBound - (count - n))
|
||||
return UnicodeScalar(r.upperBound - (count - n))!
|
||||
}
|
||||
}
|
||||
_preconditionFailure("Index out of range")
|
||||
|
||||
Reference in New Issue
Block a user