Uh oh!
There was an error while loading. Please reload this page.
rust: enhance PointerWrapper. - #386
Conversation
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
v1 -> v2
|
| // so it is safe to dereference the raw pointer. | ||
| // The safety requirements also ensure that the object remains alive for the lifetime of | ||
| // the returned value. | ||
| unsafe { UnsafeReference::new(&*(ptr as *const T)) } |
There was a problem hiding this comment.
Nit: left out a cast() here?
There was a problem hiding this comment.
Oops. I had missed this one because it goes away when I update Ref's implementation.
Anyway, fixed it now. PTAL.
This formalises how wrapped values can be accessed after they've been converted to 'pointers'. In upcoming PRs, we will have `Box<T>` instances access `&T`, but `Ref<T>` will provide access to `&Ref<T>` so that we can increment the refcount when needed. Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
ksquirrel
commented
Jun 23, 2021
Review of
|
| /// | ||
| /// `ptr` must have been returned by a previous call to [`PointerWrapper::into_pointer`]. | ||
| /// Additionally, [`PointerWrapper::from_pointer`] can only be called after *all* values | ||
| /// returned by [`PointerWrapper::borrow`] have been dropped. |
There was a problem hiding this comment.
Are there a couple of safety constraints we've omitted here?
Following these # Safety instructions, are we allowed to:
- call
from_pointer()multiple times on the same pointer? - call
borrow()after the call tofrom_pointer()?
If so, does this merit a follow-up PR?
There was a problem hiding this comment.
Yes, this should be clarified. I'll prepare a follow-up PR.
This formalises how wrapped values can be accessed after they've been
converted to 'pointers'.
In upcoming PRs, we will have
Box<T>instances access&T, butRef<T>will provide access to&Ref<T>so that we can increment therefcount when needed.
Signed-off-by: Wedson Almeida Filho wedsonaf@google.com