pub struct Shared<'g, T> { /* private fields */ }Expand description
A pointer to a heap-allocated value protected by a guard.
This type represents a pointer that is guaranteed to remain valid for the lifetime of the guard. It cannot outlive the guard.
§Safety
The pointer is only valid while the guard is alive. Dereferencing the pointer after the guard is dropped is undefined behavior.
Implementations§
Sourcepub unsafe fn from_raw(ptr: *mut T) -> Self
pub unsafe fn from_raw(ptr: *mut T) -> Self
Creates a shared pointer from a raw pointer.
§Safety
The caller must ensure the pointer is valid and will remain valid for the lifetime of the guard.
Sourcepub unsafe fn as_ref(&self) -> Option<&'g T>
pub unsafe fn as_ref(&self) -> Option<&'g T>
Converts to an optional reference.
§Safety
The caller must ensure the pointer is properly aligned and points
to a valid value of type T.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more