@@ -291,10 +291,10 @@ public extension CustomNSError {
291
291
}
292
292
}
293
293
294
- /// Convert an arbitrary binary integer to an Int, reinterpreting signed ->
295
- /// unsigned if needed but trapping if the result is otherwise not
296
- /// expressible.
297
- func unsafeBinaryIntegerToInt < T: BinaryInteger > ( _ value: T ) -> Int {
294
+ /// Convert an arbitrary fixed-width integer to an Int, reinterpreting
295
+ /// signed -> unsigned if needed but trapping if the result is otherwise
296
+ /// not expressible.
297
+ func unsafeFixedWidthIntegerToInt < T: FixedWidthInteger > ( _ value: T ) -> Int {
298
298
if T . isSigned {
299
299
return numericCast ( value)
300
300
}
@@ -303,10 +303,10 @@ func unsafeBinaryIntegerToInt<T: BinaryInteger>(_ value: T) -> Int {
303
303
return Int ( bitPattern: uintValue)
304
304
}
305
305
306
- /// Convert from an Int to an arbitrary binary integer, reinterpreting signed
307
- /// -> unsigned if needed but trapping if the result is otherwise not
306
+ /// Convert from an Int to an arbitrary fixed-width integer, reinterpreting
307
+ /// signed -> unsigned if needed but trapping if the result is otherwise not
308
308
/// expressible.
309
- func unsafeBinaryIntegerFromInt < T: BinaryInteger > ( _ value: Int ) -> T {
309
+ func unsafeFixedWidthIntegerFromInt < T: FixedWidthInteger > ( _ value: Int ) -> T {
310
310
if T . isSigned {
311
311
return numericCast ( value)
312
312
}
@@ -315,10 +315,10 @@ func unsafeBinaryIntegerFromInt<T: BinaryInteger>(_ value: Int) -> T {
315
315
return numericCast ( uintValue)
316
316
}
317
317
318
- extension CustomNSError where Self: RawRepresentable , Self. RawValue: BinaryInteger {
318
+ extension CustomNSError where Self: RawRepresentable , Self. RawValue: FixedWidthInteger {
319
319
// The error code of Error with integral raw values is the raw value.
320
320
public var errorCode : Int {
321
- return unsafeBinaryIntegerToInt ( self . rawValue)
321
+ return unsafeFixedWidthIntegerToInt ( self . rawValue)
322
322
}
323
323
}
324
324
@@ -330,7 +330,7 @@ public extension Error where Self : CustomNSError {
330
330
var _code : Int { return self . errorCode }
331
331
}
332
332
333
- public extension Error where Self: CustomNSError , Self: RawRepresentable , Self. RawValue: BinaryInteger {
333
+ public extension Error where Self: CustomNSError , Self: RawRepresentable , Self. RawValue: FixedWidthInteger {
334
334
/// Default implementation for customized NSErrors.
335
335
var _code : Int { return self . errorCode }
336
336
}
@@ -427,13 +427,13 @@ public protocol __BridgedNSError : Error {
427
427
}
428
428
429
429
// Allow two bridged NSError types to be compared.
430
- extension __BridgedNSError where Self: RawRepresentable , Self. RawValue: BinaryInteger {
430
+ extension __BridgedNSError where Self: RawRepresentable , Self. RawValue: FixedWidthInteger {
431
431
public static func == ( lhs: Self , rhs: Self ) -> Bool {
432
432
return lhs. rawValue == rhs. rawValue
433
433
}
434
434
}
435
435
436
- extension __BridgedNSError where Self: RawRepresentable , Self. RawValue: BinaryInteger {
436
+ extension __BridgedNSError where Self: RawRepresentable , Self. RawValue: FixedWidthInteger {
437
437
public var _domain : String { return Self . _nsErrorDomain }
438
438
public var _code : Int {
439
439
return Int ( rawValue)
@@ -485,16 +485,16 @@ public protocol _BridgedStoredNSError : __BridgedNSError, _ObjectiveCBridgeableE
485
485
}
486
486
487
487
/// Various helper implementations for _BridgedStoredNSError
488
- extension _BridgedStoredNSError where Code: RawRepresentable , Code. RawValue: BinaryInteger {
488
+ extension _BridgedStoredNSError where Code: RawRepresentable , Code. RawValue: FixedWidthInteger {
489
489
public var code : Code {
490
- return Code ( rawValue: unsafeBinaryIntegerFromInt ( _nsError. code) ) !
490
+ return Code ( rawValue: unsafeFixedWidthIntegerFromInt ( _nsError. code) ) !
491
491
}
492
492
493
493
/// Initialize an error within this domain with the given ``code``
494
494
/// and ``userInfo``.
495
495
public init ( _ code: Code , userInfo: [ String : Any ] = [ : ] ) {
496
496
self . init ( _nsError: NSError ( domain: Self . _nsErrorDomain,
497
- code: unsafeBinaryIntegerToInt ( code. rawValue) ,
497
+ code: unsafeFixedWidthIntegerToInt ( code. rawValue) ,
498
498
userInfo: userInfo) )
499
499
}
500
500
0 commit comments