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-3782] UnsafeMutable[Raw]BufferPointer should have nonmutating subscript setters #46367
Comments
I'm not even sure this needs a proposal. It seems like clearly just a bug. |
Inclined to agree; removing "proposal" tag |
Comment by Sergey Minakov (JIRA) Is this bug present only on UnsafeMutableBufferPointer<Type> with range subscript as it's the only setter on marked with 'nonmutating' attribute? I would like to fix it, but don't quite get it yet. |
Sorry naithar (JIRA User), I don't follow your question. Care to rephrase? In case it helps, the reason for this bug is that despite its conformance to Collection, UnsafeMutable[Raw]BufferPointer has the semantics of a pointer; it does not own its elements, so mutating the elements should not be seen as a mutation of the buffer pointer. |
Comment by Sergey Minakov (JIRA) @dabrahams sorry 🙂 |
naithar (JIRA User)Yes I think you understood correctly! |
Comment by Sergey Minakov (JIRA) @dabrahams is there any preferable way to implement this? |
#12504 implements a nonmutating range setter for UnsafeMutableBufferPointer. The other setters are nonmutating at this point. |
#12504 got merged; marking this as resolved. |
Additional Detail from JIRA
md5: c6e90cbea7ac8a60db87d54f8bb5e834
Issue Description:
...as befits a thing with reference semantics. Otherwise, you need to copy it into a mutable variable just to mutate the buffer it points at (yick).
The text was updated successfully, but these errors were encountered: