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 {
523523 validating codeUnits: some Sequence < Encoding . CodeUnit > ,
524524 as encoding: Encoding . Type
525525 ) {
526- let newString : String ? ? = codeUnits. withContiguousStorageIfAvailable {
526+ let contiguousResult = codeUnits. withContiguousStorageIfAvailable {
527527 String . _validate ( $0, as: Encoding . self)
528528 }
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
532534 return
533535 }
534536
@@ -583,14 +585,16 @@ extension String {
583585 validating codeUnits: some Sequence < Int8 > ,
584586 as encoding: Encoding . Type
585587 ) where Encoding: Unicode . Encoding , Encoding. CodeUnit == UInt8 {
586- let newString : String ? ? = codeUnits. withContiguousStorageIfAvailable {
588+ let contiguousResult = codeUnits. withContiguousStorageIfAvailable {
587589 $0. withMemoryRebound ( to: UInt8 . self) {
588590 String . _validate ( $0, as: Encoding . self)
589591 }
590592 }
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
594598 return
595599 }
596600
You can’t perform that action at this time.
0 commit comments