[][src]Struct rel_ptr::RelPtr

#[repr(transparent)]
pub struct RelPtr<T: ?Sized, I: Delta = isize>(_, _);

This represents a relative pointers

A relative pointer stores an offset, and uses its that in combination with its current position in memory to point to a value

See crate documentation for more information

Methods

impl<T, I: Delta> RelPtr<T, I>[src]

pub fn null() -> Self[src]

A null relative pointer has an offset of 0, (points to itself)

pub fn is_null(&self) -> bool[src]

Check if relative pointer is null

pub fn set(&mut self, value: &T) -> Result<(), I::Error>[src]

set the offset of a relative pointer, if the offset cannot be calculated using the given Delta, then None will be returned, and there will be no change to the offset

pub unsafe fn as_raw(&self) -> *mut T[src]

Converts the relative pointer into a normal raw pointer

Note: if self.is_null() then a null pointer will be returned

Safety

You must ensure that if RelPtr::set was called successfully before calling this function and that the value pointed to does not change it's offset relative to RelPtr

if RelPtr::set was never called successfully, this function is safe and returns None because the only way to construct a RelPtr is to make a null ptr and change it through RelPtr::set

pub unsafe fn as_raw_unchecked(&self) -> *mut T[src]

Converts the relative pointer into a normal raw pointer

Safety

You must ensure that RelPtr::set was called successfully before calling this function and that the value pointed to does not change it's offset relative to RelPtr

if RelPtr::set was never called successfully, this function is UB

pub unsafe fn as_non_null(&self) -> Option<NonNull<T>>[src]

Converts the relative pointer into a normal raw pointer

Safety

Same as RelPtr::as_raw

pub unsafe fn as_non_null_unchecked(&self) -> NonNull<T>[src]

Converts the relative pointer into a normal raw pointer

Safety

Same as RelPtr::as_raw_unchecked

pub unsafe fn as_ref(&self) -> Option<&T>[src]

Gets a reference from the relative pointer, if the relative pointer is null, then None is returned

Safety

Same as RelPtr::as_raw

pub unsafe fn as_mut(&mut self) -> Option<&mut T>[src]

Gets a mutable reference from the relative pointer, if the relative pointer is null, then None is returned

Safety

Same as RelPtr::as_raw

pub unsafe fn as_ref_unchecked(&self) -> &T[src]

Gets a reference from the relative pointer

Safety

Same as RelPtr::as_raw_unchecked

pub unsafe fn as_mut_unchecked(&mut self) -> &mut T[src]

Gets a mutable reference from the relative pointer

Safety

Same as RelPtr::as_raw_unchecked

Trait Implementations

impl<T: ?Sized, I: Delta> Clone for RelPtr<T, I>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: ?Sized, I: Delta> PartialEq<RelPtr<T, I>> for RelPtr<T, I>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<T: ?Sized, I: Delta> Eq for RelPtr<T, I>[src]

impl<T: ?Sized, I: Delta> Copy for RelPtr<T, I>[src]

Auto Trait Implementations

impl<T, I = isize> !Send for RelPtr<T, I>

impl<T, I = isize> !Sync for RelPtr<T, I>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.