@@ -390,18 +390,21 @@ extension UInt8 {
390
390
/// - Returns: `true` when the `UInt8` is equal to the provided Unicode scalar; otherwise, `false`.
391
391
@_transparent @_alwaysEmitIntoClient
392
392
public static func == ( i: Self , s: Unicode . Scalar ) -> Bool {
393
+ guard s. value < 128 else { return false }
393
394
return i == UInt8 ( ascii: s)
394
395
}
395
396
396
397
/// Returns a Boolean indicating whether the `UInt8` is not equal to the provided Unicode scalar.
397
398
@_transparent @_alwaysEmitIntoClient
398
399
public static func != ( i: Self , s: Unicode . Scalar ) -> Bool {
400
+ guard s. value < 128 else { return true }
399
401
return i != UInt8 ( ascii: s)
400
402
}
401
403
402
404
/// Enables pattern matching of Unicode scalars in switch statements.
403
405
@_transparent @_alwaysEmitIntoClient
404
406
public static func ~= ( s: Unicode . Scalar , i: Self ) -> Bool {
407
+ guard s. value < 128 else { return false }
405
408
return i == UInt8 ( ascii: s)
406
409
}
407
410
}
@@ -416,18 +419,21 @@ extension UInt8? {
416
419
/// - Returns: `true` if the optional `UInt8` is equal to the provided Unicode scalar; otherwise, `false`.
417
420
@_transparent @_alwaysEmitIntoClient
418
421
public static func == ( i: Self , s: Unicode . Scalar ) -> Bool {
422
+ guard s. value < 128 else { return false }
419
423
return i == UInt8 ( ascii: s)
420
424
}
421
425
422
426
/// Returns a Boolean value indicating whether the optional `UInt8` is not equal to the provided Unicode scalar.
423
427
@_transparent @_alwaysEmitIntoClient
424
428
public static func != ( i: Self , s: Unicode . Scalar ) -> Bool {
429
+ guard s. value < 128 else { return true }
425
430
return i != UInt8 ( ascii: s)
426
431
}
427
432
428
433
/// Allows pattern matching of Unicode scalars in switch statements.
429
434
@_transparent @_alwaysEmitIntoClient
430
435
public static func ~= ( s: Unicode . Scalar , i: Self ) -> Bool {
436
+ guard s. value < 128 else { return false }
431
437
return i == UInt8 ( ascii: s)
432
438
}
433
439
}
0 commit comments