Skip to content

Commit 30a3eae

Browse files
committed
[stdlib] add MutableSpan and MutableRawSpan
1 parent ea225d5 commit 30a3eae

File tree

5 files changed

+1061
-0
lines changed

5 files changed

+1061
-0
lines changed

stdlib/public/core/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ split_embedded_sources(
157157
EMBEDDED Slice.swift
158158
EMBEDDED SmallString.swift
159159
EMBEDDED Sort.swift
160+
EMBEDDED Span/MutableRawSpan.swift
161+
EMBEDDED Span/MutableSpan.swift
160162
EMBEDDED Span/RawSpan.swift
161163
EMBEDDED Span/Span.swift
162164
EMBEDDED StaticString.swift

stdlib/public/core/GroupInfo.json

+2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@
200200
"UnsafeRawBufferPointer.swift"
201201
],
202202
"Span": [
203+
"MutableRawSpan.swift",
204+
"MutableSpan.swift",
203205
"RawSpan.swift",
204206
"Span.swift"
205207
],

stdlib/public/core/LifetimeManager.swift

+19
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,22 @@ internal func _overrideLifetime<
297297
// should be expressed by a builtin that is hidden within the function body.
298298
dependent
299299
}
300+
301+
/// Unsafely discard any lifetime dependency on the `dependent` argument.
302+
/// Return a value identical to `dependent` with a lifetime dependency
303+
/// on the caller's exclusive borrow scope of the `source` argument.
304+
@unsafe
305+
@_unsafeNonescapableResult
306+
@_alwaysEmitIntoClient
307+
@_transparent
308+
@lifetime(borrow source)
309+
internal func _overrideLifetime<
310+
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
311+
>(
312+
_ dependent: consuming T,
313+
mutating source: inout U
314+
) -> T {
315+
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
316+
// should be expressed by a builtin that is hidden within the function body.
317+
dependent
318+
}

0 commit comments

Comments
 (0)