Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-3929] UnsafeBufferPointer should have init from mutable #46514

Closed
milseman mannequin opened this issue Feb 11, 2017 · 4 comments
Closed

[SR-3929] UnsafeBufferPointer should have init from mutable #46514

milseman mannequin opened this issue Feb 11, 2017 · 4 comments
Assignees
Labels
feature A feature request or implementation improvement standard library Area: Standard library umbrella

Comments

@milseman
Copy link
Mannequin

milseman mannequin commented Feb 11, 2017

Previous ID SR-3929
Radar rdar://problem/31236319
Original Reporter @milseman
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, LanguageFeatureRequest
Assignee @atrick
Priority Medium

md5: 6cfa9b4be4e1783cece7fcf8f1833adf

Issue Description:

UnsafeBufferPointer should have an initializer that takes a UnsafeMutableBufferPointer of the same type, and vice versa.

@atrick
Copy link
Member

atrick commented Feb 11, 2017

Yes. Other convenience methods were intentionally left out, but this one is pretty fundamental.

The nonmutating-to-mutating initializer will have a `mutating:` label.

This seems obvious enough that I can extend SE-0138, without a new proposal:
https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md

@karwa
Copy link
Contributor

karwa commented Mar 24, 2017

Another idea would be to have an `immutable` computed property on UnsafeMutableBufferPointer. Just because it's fewer characters.

Nonmutating-to-mutating should always require an explicit initialiser, of course, but it's a much less common situation.

@atrick
Copy link
Member

atrick commented Mar 24, 2017

We definitely want the initializer with no labels. I think the point of the `immutable` property would be to avoid explicitly calling that initializer, since we don't have implicit conversions on BufferPointers. I think that's another issue.

@glessard
Copy link
Contributor

glessard commented Dec 7, 2017

Implemented as part of SE-0184a

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants