-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add ability to update or operate on an Unalign
in-place
#206
Comments
joshlf
changed the title
Add ability to update
Add ability to update or operate on an Jul 29, 2023
Unalign
in-placeUnalign
in-place
joshlf
added a commit
that referenced
this issue
Aug 1, 2023
Adds the `Unalign::update` method, which allows updating an `Unalign` in-place via a callback. This works by temporarily moving the `Unalign` into the local stack frame in order to call the callback. Closes #206
joshlf
added a commit
that referenced
this issue
Aug 1, 2023
Adds the `Unalign::update` method, which allows updating an `Unalign` in-place via a callback. This works by temporarily moving the `Unalign` into the local stack frame in order to call the callback. Closes #206
joshlf
added a commit
that referenced
this issue
Aug 1, 2023
Adds the `Unalign::update` method, which allows updating an `Unalign` in-place via a callback. This works by temporarily moving the `Unalign` into the local stack frame in order to call the callback. Closes #206
joshlf
added a commit
that referenced
this issue
Aug 3, 2023
Adds the `Unalign::update` method, which allows updating an `Unalign` in-place via a callback. This works by temporarily moving the `Unalign` into the local stack frame in order to call the callback. Closes #206
joshlf
added a commit
that referenced
this issue
Aug 3, 2023
Adds the `Unalign::update` method, which allows updating an `Unalign` in-place via a callback. This works by temporarily moving the `Unalign` into the local stack frame in order to call the callback. Closes #206
joshlf
added a commit
that referenced
this issue
Aug 3, 2023
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be possible to add a method to
Unalign
which allows updating or operating in-place by doing the following:T
into the local stack frameT
T
back to the original memory location (do this even if the callback panics - it must leave the stack-local in a valid state)We would likely want one method for mutation (takes a
&mut self
and the callback operates on a&mut T
) and one for non-mutation (&self
and&T
).For the
&self
method, we would need to provide it only onUnalign<Cell<T>>
, and could likely piggy-back on #211. It may also make sense to just omit a&self
method entirely and let users transpose intoCell<Unalign<T>>
on their own and then write the same (very straightforward) code we would have.This would be expensive for large types, but we could just call that out in the documentation.
One caveat: Do we have to worry about pinning/self-referential types (whose memory address is a safety property)?
The text was updated successfully, but these errors were encountered: