Skip to content

[SR-11957] withContiguous[Mutable]StorageIfAvailable not implemented on Slice #54377

@stephentyrone

Description

@stephentyrone
Previous ID SR-11957
Radar rdar://58090587
Original Reporter @stephentyrone
Type New Feature
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels New Feature
Assignee @lorentey
Priority Medium

md5: 1e0512ad7793abdadd029d3398408f86

Issue Description:

Slice does not implement withContiguous[Mutable]StorageIfAvailable, which means it falls to the default implementation which, unconditionally nil s out, even when Base does provide a custom implementation.

This is most noticeable with Unsafe[Mutable]BufferPointer:

var a = UnsafeMutableBufferPointer<Int>.allocate(capacity: 4)
a[1...].withContiguousStorageIfAvailable { print($0) } // does not print

Providing a good implementation on Slice is somewhat tricky because we are lacking constraints on the index type of Base, but it would be nice to improve this.

Metadata

Metadata

Assignees

Labels

featureA feature request or implementationstandard libraryArea: Standard library umbrella

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions