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-3679] withUnsafeBytes and withUnsafePointer should accept immutable values #46264

Closed
jckarter opened this issue Jan 19, 2017 · 1 comment
Closed
Labels
feature A feature request or implementation good first issue Good for newcomers standard library Area: Standard library umbrella swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented

Comments

@jckarter
Copy link
Member

Previous ID SR-3679
Radar None
Original Reporter @jckarter
Type New Feature
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels New Feature, StarterProposal
Assignee None
Priority Medium

md5: 42861c4d881483879a442cc672e04591

Issue Description:

`withUnsafeBytes` and `withUnsafePointer` should work with `let` values. You can already do this today manually:

@inline(__always)
func withUnsafeBytes<T, U>(_ value: T, _ body: (UnsafeRawPointer) -> U) -> U {
  var value2 = value
  return withUnsafeBytes(&value2, body)
}

and that ought to be optimizable. (In the fullness of time, with the ownership model, `value` should be come a borrowed argument in this case, but I don't think that needs to be a blocker.)

@glessard
Copy link
Contributor

glessard commented Jun 4, 2021

Implemented in Swift 4.2, as SE-0205

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented good first issue Good for newcomers and removed new feature StarterProposal labels Nov 11, 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 good first issue Good for newcomers standard library Area: Standard library umbrella swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented
Projects
None yet
Development

No branches or pull requests

3 participants