Skip to content

Commit f5a076d

Browse files
Anton Pogonetsparkera
Anton Pogonets
authored andcommitted
Add @discardableResult to Scanner (#1624)
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 1741fc5 commit f5a076d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Foundation/Scanner.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,60 +419,70 @@ extension String {
419419
extension Scanner {
420420

421421
// On overflow, the below methods will return success and clamp
422+
@discardableResult
422423
public func scanInt32(_ result: UnsafeMutablePointer<Int32>) -> Bool {
423424
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int32) -> Void in
424425
result.pointee = value
425426
}
426427
}
427428

429+
@discardableResult
428430
public func scanInt(_ result: UnsafeMutablePointer<Int>) -> Bool {
429431
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int) -> Void in
430432
result.pointee = value
431433
}
432434
}
433435

436+
@discardableResult
434437
public func scanInt64(_ result: UnsafeMutablePointer<Int64>) -> Bool {
435438
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: Int64) -> Void in
436439
result.pointee = value
437440
}
438441
}
439442

443+
@discardableResult
440444
public func scanUnsignedLongLong(_ result: UnsafeMutablePointer<UInt64>) -> Bool {
441445
return _scanString.scan(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt64) -> Void in
442446
result.pointee = value
443447
}
444448
}
445449

450+
@discardableResult
446451
public func scanFloat(_ result: UnsafeMutablePointer<Float>) -> Bool {
447452
return _scanString.scan(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Float) -> Void in
448453
result.pointee = value
449454
}
450455
}
451456

457+
@discardableResult
452458
public func scanDouble(_ result: UnsafeMutablePointer<Double>) -> Bool {
453459
return _scanString.scan(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Double) -> Void in
454460
result.pointee = value
455461
}
456462
}
457463

464+
@discardableResult
458465
public func scanHexInt32(_ result: UnsafeMutablePointer<UInt32>) -> Bool {
459466
return _scanString.scanHex(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt32) -> Void in
460467
result.pointee = value
461468
}
462469
}
463470

471+
@discardableResult
464472
public func scanHexInt64(_ result: UnsafeMutablePointer<UInt64>) -> Bool {
465473
return _scanString.scanHex(_skipSet, locationToScanFrom: &_scanLocation) { (value: UInt64) -> Void in
466474
result.pointee = value
467475
}
468476
}
469477

478+
@discardableResult
470479
public func scanHexFloat(_ result: UnsafeMutablePointer<Float>) -> Bool {
471480
return _scanString.scanHex(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Float) -> Void in
472481
result.pointee = value
473482
}
474483
}
475484

485+
@discardableResult
476486
public func scanHexDouble(_ result: UnsafeMutablePointer<Double>) -> Bool {
477487
return _scanString.scanHex(_skipSet, locale: locale, locationToScanFrom: &_scanLocation) { (value: Double) -> Void in
478488
result.pointee = value
@@ -607,6 +617,7 @@ extension Scanner {
607617
}
608618
}
609619

620+
@discardableResult
610621
public func scanString(_ string:String, into ptr: UnsafeMutablePointer<String?>?) -> Bool {
611622
if let str = scanString(string) {
612623
ptr?.pointee = str
@@ -680,6 +691,7 @@ extension Scanner {
680691
return nil
681692
}
682693

694+
@discardableResult
683695
public func scanUpToCharacters(from set: CharacterSet, into ptr: UnsafeMutablePointer<String?>?) -> Bool {
684696
if let result = scanUpToCharactersFromSet(set) {
685697
ptr?.pointee = result

0 commit comments

Comments
 (0)