pub struct CompactPtr<T: CompactRepr> { /* private fields */ }Implementations§
Source§impl<T: CompactRepr> CompactPtr<T>
impl<T: CompactRepr> CompactPtr<T>
pub fn is_null(self) -> bool
Sourcepub unsafe fn as_ref(self) -> Option<Compact<T>>
pub unsafe fn as_ref(self) -> Option<Compact<T>>
Returns the element the pointer references, or None if it is null.
§Safety
If non-null, self.packed must point to valid Store<T> storage
(or, for a direct pointer, to a live T) and self.index must
address an initialized element within it. The caller must ensure the
backing storage remains live while the returned value is used.
Sourcepub fn as_mut_ptr(&self) -> CompactPtrMut<T>
pub fn as_mut_ptr(&self) -> CompactPtrMut<T>
Direct pointers convert to a null mutable pointer: they borrow a standalone value immutably, so there is no storage a write could legally target.
Sourcepub unsafe fn offset(self, count: isize) -> CompactPtr<T>
pub unsafe fn offset(self, count: isize) -> CompactPtr<T>
Produces a pointer offset by count elements (analogous to
pointer::offset).
§Safety
The resulting index (self.index + count) must be in bounds or one
past the end of the same allocated backing storage.
Sourcepub unsafe fn add(self, count: usize) -> CompactPtr<T>
pub unsafe fn add(self, count: usize) -> CompactPtr<T>
Produces a pointer advanced by count elements (analogous to
pointer::add).
§Safety
The resulting index (self.index + count) must be in bounds or one
past the end of the same allocated backing storage.
Sourcepub unsafe fn sub(self, count: usize) -> CompactPtr<T>
pub unsafe fn sub(self, count: usize) -> CompactPtr<T>
Produces a pointer moved back by count elements (analogous to
pointer::sub).
§Safety
count must not exceed self.index; the resulting index must be in
bounds of the same allocated backing storage.
Sourcepub unsafe fn read(self) -> Compact<T>
pub unsafe fn read(self) -> Compact<T>
Reads the element the pointer references (analogous to
pointer::read).
§Safety
self.packed must point to valid Store<T> storage (or, for a
direct pointer, to a live T) and self.index must address an
initialized element within it.
Trait Implementations§
Source§impl<T: Clone + CompactRepr> Clone for CompactPtr<T>
impl<T: Clone + CompactRepr> Clone for CompactPtr<T>
Source§fn clone(&self) -> CompactPtr<T>
fn clone(&self) -> CompactPtr<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more