pub struct TaggedPtr<T> {
pub ptr: Ptr<T>,
pub tag: Tag,
}Expand description
A packaged representation of a pointer and a generation tag.
Used for atomic operations with AtomicTaggedPtr.
Fields§
§ptr: Ptr<T>The physical pointer wrapper.
tag: TagThe generation tag for ABA protection.
Implementations§
Source§impl<T> TaggedPtr<T>
impl<T> TaggedPtr<T>
Sourcepub fn decompose(self) -> (Ptr<T>, Tag)
pub fn decompose(self) -> (Ptr<T>, Tag)
Deconstructs the TaggedPtr into a tuple of (Ptr<T>, Tag).
Sourcepub fn as_ptr(self) -> *const T
pub fn as_ptr(self) -> *const T
Converts the pointer into a raw const pointer *const T.
Returns a null pointer if the underlying value is None.
Sourcepub fn as_mut_ptr(self) -> *mut T
pub fn as_mut_ptr(self) -> *mut T
Converts the pointer into a raw mutable pointer *mut T.
Returns a null pointer if the underlying value is None.
Sourcepub unsafe fn as_ref<'a>(self) -> Option<&'a T>
pub unsafe fn as_ref<'a>(self) -> Option<&'a T>
Returns a shared reference to the value if the pointer is not null.
§Safety
The caller must ensure that the pointer is valid, aligned, points to a valid initialized value, and respects the aliasing rules of Rust references.
Sourcepub unsafe fn as_mut<'a>(self) -> Option<&'a mut T>
pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T>
Returns a mutable reference to the value if the pointer is not null.
§Safety
The caller must ensure that the pointer is valid, aligned, points to a valid initialized value, and respects the aliasing rules of Rust references.
Sourcepub fn with_ptr<U>(self, ptr: impl Into<Ptr<U>>) -> TaggedPtr<U>
pub fn with_ptr<U>(self, ptr: impl Into<Ptr<U>>) -> TaggedPtr<U>
Returns a new TaggedPtr with a different pointer but the same tag.