File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -523,12 +523,14 @@ extension String {
523
523
validating codeUnits: some Sequence < Encoding . CodeUnit > ,
524
524
as encoding: Encoding . Type
525
525
) {
526
- let newString : String ? ? = codeUnits. withContiguousStorageIfAvailable {
526
+ let contiguousResult = codeUnits. withContiguousStorageIfAvailable {
527
527
String . _validate ( $0, as: Encoding . self)
528
528
}
529
- if let newString {
530
- guard let newString else { return nil }
531
- self = newString
529
+ if let validationResult = contiguousResult {
530
+ guard let validatedString = validationResult else {
531
+ return nil
532
+ }
533
+ self = validatedString
532
534
return
533
535
}
534
536
@@ -583,14 +585,16 @@ extension String {
583
585
validating codeUnits: some Sequence < Int8 > ,
584
586
as encoding: Encoding . Type
585
587
) where Encoding: Unicode . Encoding , Encoding. CodeUnit == UInt8 {
586
- let newString : String ? ? = codeUnits. withContiguousStorageIfAvailable {
588
+ let contiguousResult = codeUnits. withContiguousStorageIfAvailable {
587
589
$0. withMemoryRebound ( to: UInt8 . self) {
588
590
String . _validate ( $0, as: Encoding . self)
589
591
}
590
592
}
591
- if let newString {
592
- guard let newString else { return nil }
593
- self = newString
593
+ if let validationResult = contiguousResult {
594
+ guard let validatedString = validationResult else {
595
+ return nil
596
+ }
597
+ self = validatedString
594
598
return
595
599
}
596
600
You can’t perform that action at this time.
0 commit comments