You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slice does not implement withContiguous[Mutable]StorageIfAvailable, which means it falls to the default implementation which, unconditionally nil s out, even when Basedoes 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.
The text was updated successfully, but these errors were encountered:
Note for anyone hitting this: you can always work around it by slicing the UnsafeMutableBufferPointer passed to the closure instead, though that's not as ergonomic in all cases.
Additional Detail from JIRA
md5: 1e0512ad7793abdadd029d3398408f86
Issue Description:
Slice does not implement
withContiguous[Mutable]StorageIfAvailable
, which means it falls to the default implementation which, unconditionallynil
s out, even whenBase
does provide a custom implementation.This is most noticeable with
Unsafe[Mutable]BufferPointer
: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.
The text was updated successfully, but these errors were encountered: