Add method to clear WRITEABLE
flag from PyArray
#462
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
PyReadwriteArray
understands the flag during the dynamic borrow checking, this just adds a way to set it on an array as well. This is a safe subset of what can be achieved unsafely by mutating theflags
field on some*mut PyArray
.The discussion in #456 suggested having the method return a
PyReadonlyArray
. I feel like I might be missing something very obvious here, but I couldn't spot an existing way to consume an exclusive reference into a shared one. I added aFrom
impl and then used that for now, but happy to switch it to a better version if one already exists, or drop it if we decide we don't want users to always pay the cost of re-acquiring the shared borrow (maybe there's somemem::forget
shenanigans in conjunction with an extra "switch in place" operation that could be added toShared
to reduce the cost).