-
Notifications
You must be signed in to change notification settings - Fork 19
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
various improvements for the new design #28
various improvements for the new design #28
Conversation
Thanks a lot for opening this and for continuing the work on the new design! Most of the improvements look good to me, but I don't think that implementing To solve the problem that you mentioned in #22 (comment), we could add additional |
I wouldn't say that we don't gain any safety guarantess over
The problem with that is that, we'd need to duplicate a lot of different methods:
And maybe Another way that doesn't need duplicate methods, but is probably very verbose, would be to force explicitly reborrowing by making all those methods I listed above take |
The If this approach doesn't work for some reason, I'm also fine with duplicating the relevant methods. It's a bit of duplication, but I don't think that this is really a problem. We already have |
9729030
to
b9e0607
Compare
I've pushed my current work-in-progress state. Most of the functionally should be implemented, but it's still missing documentation. I think if we go with this approach we can also get rid of the |
First of all, I like this design. Having the The main downside of Given the complexities and subtleties involved here, I think requiring a user to override our default of
This would match the traits for
|
980f3c3
to
cd57be9
Compare
@josephlr Thanks a lot for your thoughts! I'm sorry for replying so late. I fully agree that making Given that this PR in its current state is a strict improvement to #22, I think it's a good idea to merge it and continue the discussion in #22. |
@Freax13 Thanks a lot for your work on this PR and sorry for the long delay! |
This pr brings various improvements for the new design:
Self
by value, not by reference*mut T
#22 (comment)implementCopy
forVolatilePtr
This is a requirement for the previous change.Replaced byVolatilePtr<'a, T>
now behaves a lot like&'a Cell<T>
in that it allows reading and writing to a memory location with a copy-able non-unique handle.borrow
andborrow_mut
.VolatilePtr::as_slice_mut
VolatilePtr::as_slice
already existed, but didn't give out writableVolatilePtr
sVolatilePtr::iter
andVolatilePtr::iter_mut
to make it easier to iterator over all elements of a sliceVolatilePtr::<[T]>::is_empty
VolatilePtr::<[T]>::len
, so users would probably expect.is_empty()
to work toomap_field!
reject unaligned fieldsaddGeneric types are inlineable anyways#[inline]
to most functionsI didn't want to create multiple prs, so this pr has unrelated changes. Feel free to pick and choose which improvements you want to use in the new design.
I've been using the new design pretty much since #22 was created. I worked around some of the missing functions (e.g.
as_slice_mut
), but I couldn't do that for some of the bigger changes such as making methods takeSelf
by value. So, instead of adding a new layer of workarounds, I decided to ignore that the #22 is not done yet and create a pr to it.Related to #22