Skip to content

Commit 579f8a2

Browse files
authored
Add @discardableResult to Scanner
On Darwin public methods with out parameters not produce "result call unused" warning So using @discardableResult here is behave more like Darwin Foundation
1 parent 91e5c25 commit 579f8a2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Foundation/Scanner.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,60 +391,70 @@ extension String {
391391
extension Scanner {
392392

393393
// On overflow, the below methods will return success and clamp
394+
@discardableResult
394395
public func scanInt32(_ result: UnsafeMutablePointer<Int32>) -> Bool {
395396
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int32) -> Void in
396397
result.pointee = value
397398
}
398399
}
399400

401+
@discardableResult
400402
public func scanInt(_ result: UnsafeMutablePointer<Int>) -> Bool {
401403
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int) -> Void in
402404
result.pointee = value
403405
}
404406
}
405407

408+
@discardableResult
406409
public func scanInt64(_ result: UnsafeMutablePointer<Int64>) -> Bool {
407410
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int64) -> Void in
408411
result.pointee = value
409412
}
410413
}
411414

415+
@discardableResult
412416
public func scanUnsignedLongLong(_ result: UnsafeMutablePointer<UInt64>) -> Bool {
413417
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt64) -> Void in
414418
result.pointee = value
415419
}
416420
}
417421

422+
@discardableResult
418423
public func scanFloat(_ result: UnsafeMutablePointer<Float>) -> Bool {
419424
return _scanString.scan(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Float) -> Void in
420425
result.pointee = value
421426
}
422427
}
423428

429+
@discardableResult
424430
public func scanDouble(_ result: UnsafeMutablePointer<Double>) -> Bool {
425431
return _scanString.scan(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Double) -> Void in
426432
result.pointee = value
427433
}
428434
}
429435

436+
@discardableResult
430437
public func scanHexInt32(_ result: UnsafeMutablePointer<UInt32>) -> Bool {
431438
return _scanString.scanHex(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt32) -> Void in
432439
result.pointee = value
433440
}
434441
}
435442

443+
@discardableResult
436444
public func scanHexInt64(_ result: UnsafeMutablePointer<UInt64>) -> Bool {
437445
return _scanString.scanHex(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt64) -> Void in
438446
result.pointee = value
439447
}
440448
}
441449

450+
@discardableResult
442451
public func scanHexFloat(_ result: UnsafeMutablePointer<Float>) -> Bool {
443452
return _scanString.scanHex(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Float) -> Void in
444453
result.pointee = value
445454
}
446455
}
447456

457+
@discardableResult
448458
public func scanHexDouble(_ result: UnsafeMutablePointer<Double>) -> Bool {
449459
return _scanString.scanHex(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Double) -> Void in
450460
result.pointee = value
@@ -652,6 +662,7 @@ extension Scanner {
652662
return nil
653663
}
654664

665+
@discardableResult
655666
public func scanUpToCharacters(from set: CharacterSet, into ptr: UnsafeMutablePointer<String?>?) -> Bool {
656667
if let result = scanUpToCharactersFromSet(set) {
657668
ptr?.pointee = result

0 commit comments

Comments
 (0)