@@ -141,6 +141,24 @@ extension RawSpan {
141
141
self . init ( _unsafeBytes: UnsafeRawBufferPointer ( buffer) )
142
142
}
143
143
144
+ /// Unsafely create a `RawSpan` over initialized memory.
145
+ ///
146
+ /// The memory in `buffer` must be valid and initialized
147
+ /// for at least as long as the returned `RawSpan` exists.
148
+ ///
149
+ /// - Parameters:
150
+ /// - buffer: a raw buffer to initialized memory.
151
+ @_disallowFeatureSuppression ( NonescapableTypes)
152
+ @_alwaysEmitIntoClient
153
+ @lifetime ( immortal)
154
+ public init < T: BitwiseCopyable > (
155
+ _unsafeElements buffer: borrowing Slice < UnsafeBufferPointer < T > >
156
+ ) {
157
+ self . init (
158
+ _unsafeBytes: . init( UnsafeBufferPointer ( rebasing: buffer) )
159
+ )
160
+ }
161
+
144
162
/// Unsafely create a `RawSpan` over initialized memory.
145
163
///
146
164
/// The memory in `buffer` must be owned by the instance `owner`,
@@ -159,6 +177,24 @@ extension RawSpan {
159
177
self . init ( _unsafeElements: UnsafeBufferPointer ( buffer) )
160
178
}
161
179
180
+ /// Unsafely create a `RawSpan` over initialized memory.
181
+ ///
182
+ /// The memory in `buffer` must be valid and initialized
183
+ /// for at least as long as the returned `RawSpan` exists.
184
+ ///
185
+ /// - Parameters:
186
+ /// - buffer: a raw buffer to initialized memory.
187
+ @_disallowFeatureSuppression ( NonescapableTypes)
188
+ @_alwaysEmitIntoClient
189
+ @lifetime ( immortal)
190
+ public init < T: BitwiseCopyable > (
191
+ _unsafeElements buffer: borrowing Slice < UnsafeMutableBufferPointer < T > >
192
+ ) {
193
+ self . init (
194
+ _unsafeBytes: . init( UnsafeBufferPointer ( rebasing: buffer) )
195
+ )
196
+ }
197
+
162
198
/// Unsafely create a `RawSpan` over initialized memory.
163
199
///
164
200
/// The memory over `count` bytes starting at
0 commit comments