Skip to content

Commit 4b9cd93

Browse files
committed
wip
1 parent 05c5564 commit 4b9cd93

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

stdlib/public/core/UTF8Span.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,34 @@ extension UTF8Span {
243243

244244
}
245245

246+
@available(SwiftStdlib 6.1, *)
247+
extension UTF8Span {
248+
public static func ~=(_ lhs: StaticString, _ rhs: UTF8Span) -> Bool {
249+
return lhs.withUTF8Buffer { str in
250+
rhs._withUnsafeBufferPointer { span in
251+
str.elementsEqual(span)
252+
}
253+
}
254+
}
255+
}
256+
257+
246258
func TODO(_ message: String) -> Never {
247-
fatalError("TODO: message")
259+
fatalError("TODO: \(message)")
248260
}
249261

250262
// TODO(toolchain): decide if we rebase on top of Guillaume's work
251263
@available(SwiftStdlib 6.1, *)
252264
extension String {
253265
public var utf8Span: UTF8Span {
254-
TODO("Decide when to rebase on top of Guillaume's PR")
266+
TODO("Decide whether to rebase on top of Span PR or wait for merge")
255267
}
256268
}
257269

258270
@available(SwiftStdlib 6.1, *)
259271
extension Substring {
260272
public var utf8Span: UTF8Span {
261-
TODO("Decide when to rebase on top of Guillaume's PR")
273+
TODO("Decide whether to rebase on top of Span PR or wait for merge")
262274
}
263275
}
264276

stdlib/public/core/UTF8SpanBits.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension UTF8Span {
6767
if s.value < 0x300 {
6868
continue
6969
}
70-
TODO("Adapt _StringGutsSlice._fastNFCCheck()")
70+
TODO("Refactor and adapt _StringGutsSlice._fastNFCCheck()")
7171
}
7272
self._countAndFlags |= Self._nfcBit
7373
return true

test/stdlib/UTF8SpanIteratorTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ struct ContentEquivalenceTestCase {
3434

3535
func withUTF8Span<R>(_ f: (UTF8Span) throws -> R) rethrows -> R {
3636
try Array(str.utf8).withSpan { span in
37-
try f(try! UTF8Span(_validating: span))
37+
try f(try! UTF8Span(validating: span))
3838
}
3939
}
4040

4141
func testBytes() {
4242
let otherBytes = Array((str+"abc").utf8)
4343

4444
withUTF8Span { utf8Span in
45-
utf8Span.withUnsafeBufferPointer {
45+
utf8Span._withUnsafeBufferPointer {
4646
expectEqualSequence(str.utf8, $0, stackTrace: loc)
4747
}
4848
}

test/stdlib/UTF8SpanQueriesComparisons.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension Array where Element == UInt8 {
1717
}
1818
func withUTF8Span<R>(_ f: (UTF8Span) throws -> R) rethrows -> R {
1919
try self.withSpan { span in
20-
try f(try! UTF8Span(_validating: span))
20+
try f(try! UTF8Span(validating: span))
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)