We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc1227f commit 8456d22Copy full SHA for 8456d22
test/1_stdlib/TestData.swift
@@ -128,8 +128,10 @@ class TestData : TestDataSuper {
128
func dataFrom(_ string : String) -> Data {
129
// Create a Data out of those bytes
130
return string.utf8CString.withUnsafeBufferPointer { (ptr) in
131
- // Subtract 1 so we don't get the null terminator byte. This matches NSString behavior.
132
- return Data(bytes: UnsafeRawPointer(ptr.baseAddress!), count: ptr.count - 1)
+ ptr.baseAddress!.withMemoryRebound(to: UInt8.self, capacity: ptr.count) {
+ // Subtract 1 so we don't get the null terminator byte. This matches NSString behavior.
133
+ return Data(bytes: $0, count: ptr.count - 1)
134
+ }
135
}
136
137
0 commit comments