pub struct ValueGuard<T> { /* private fields */ }Expand description
Strong guard for granting read access to a single interior mutable value to
RefGuard.
A ValueGuard:RefGuard relationship is exclusive, and behaves similarly
to a single Rc and Weak pair, but notably does not require heap
allocation. ValueGuard::registration creates a GuardRegistration, which
provides a movable wrapper for safety creating the circular references
between two pinned self referential structs.
§Safety
This struct must not be leaked to the stack using mem::forget or any
other mechanism that causes the contents of Self to be overwritten
without Drop::drop() running.
Doing so creates unsoundness that likely will lead to dereferencing a null
pointer.
Note that it is sound to leak Self to the heap using methods including
Box::leak() because heap allocated data will never be overwritten if it
is never freed.
Implementations§
Source§impl<T> ValueGuard<T>
impl<T> ValueGuard<T>
Sourcepub fn registration<'a>(self: Pin<&'a Self>) -> GuardRegistration<'a, T>
pub fn registration<'a>(self: Pin<&'a Self>) -> GuardRegistration<'a, T>
Returns a GuardRegistration, which can be used to safety link Self
to a RefGuard.