Skip to content

Commit 38ecaa5

Browse files
committed
[stdlib] add MutableSpan and MutableRawSpan
1 parent 20a29fe commit 38ecaa5

File tree

5 files changed

+1061
-0
lines changed

5 files changed

+1061
-0
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ split_embedded_sources(
155155
EMBEDDED Slice.swift
156156
EMBEDDED SmallString.swift
157157
EMBEDDED Sort.swift
158+
EMBEDDED Span/MutableRawSpan.swift
159+
EMBEDDED Span/MutableSpan.swift
158160
EMBEDDED Span/RawSpan.swift
159161
EMBEDDED Span/Span.swift
160162
EMBEDDED StaticString.swift

stdlib/public/core/GroupInfo.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@
199199
"UnsafeRawBufferPointer.swift"
200200
],
201201
"Span": [
202+
"MutableRawSpan.swift",
203+
"MutableSpan.swift",
202204
"RawSpan.swift",
203205
"Span.swift"
204206
],

stdlib/public/core/LifetimeManager.swift

Lines changed: 19 additions & 0 deletions
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)