Struct primordial::Address
source · [−]#[repr(transparent)]pub struct Address<T, U>(_, _);
Expand description
An address
This newtype is used to represent addresses of a given type.
The most important invariant of this type is that the address is always
properly aligned for the given type U
. The only way to convert between
addresses of different types is to choose a new alignment (raise or lower).
This type does not, however, track lifetime. You’re on your own.
Unlike the naked underlying types, you can infallibly convert between,
for example, an Address<usize, ()>
and an Address<u64, ()>
wherever
such a conversion is lossless given the target CPU architecture.
Implementations
sourceimpl<T, U> Address<T, U>
impl<T, U> Address<T, U>
sourcepub const unsafe fn unchecked(value: T) -> Self
pub const unsafe fn unchecked(value: T) -> Self
Creates a new Address
from a raw inner type without checking
Safety
This function is unsafe because it does not enforce the main constraint of this type that the address stored is properly aligned to the type.
For a safe version of this constructor, first create an Address<T, ()>
from the raw value and then align to the type you want.
sourceimpl<T, U> Address<T, U> where
Self: Into<Address<usize, U>>,
impl<T, U> Address<T, U> where
Self: Into<Address<usize, U>>,
sourcepub fn as_ptr(self) -> *const U
pub fn as_ptr(self) -> *const U
Returns a raw pointer to its inner type
Safety
Behavior is undefined, if the pointer is used and is not aligned or points to uninitialized memory.
sourcepub fn as_mut_ptr(self) -> *mut U
pub fn as_mut_ptr(self) -> *mut U
Returns a raw pointer to its inner type
Safety
Behavior is undefined, if the pointer is used and is not aligned or points to uninitialized memory.
Trait Implementations
sourceimpl<T, U> Add<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Add<T, Output = T>,
impl<T, U> Add<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Add<T, Output = T>,
sourceimpl<T, U> AddAssign<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: AddAssign<T>,
impl<T, U> AddAssign<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: AddAssign<T>,
sourcefn add_assign(&mut self, rhs: Offset<T, U>)
fn add_assign(&mut self, rhs: Offset<T, U>)
Performs the +=
operation. Read more
sourceimpl<T, U> From<&'_ U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
impl<T, U> From<&'_ U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
Convert a reference to an Address
with the same type
sourceimpl<T, U> From<*const U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
impl<T, U> From<*const U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
Convert a const pointer to an Address
with the same type
sourceimpl<T, U> From<*mut U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
impl<T, U> From<*mut U> for Address<T, U> where
Address<usize, U>: Into<Address<T, U>>,
Convert a mutable pointer to an Address
with the same type
sourceimpl<T: Ord, U> Ord for Address<T, U>
impl<T: Ord, U> Ord for Address<T, U>
sourceimpl<T: PartialOrd, U> PartialOrd<Address<T, U>> for Address<T, U>
impl<T: PartialOrd, U> PartialOrd<Address<T, U>> for Address<T, U>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T, U> Sub<Address<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Sub<T, Output = T>,
T: Div<T, Output = T>,
T: One,
impl<T, U> Sub<Address<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Sub<T, Output = T>,
T: Div<T, Output = T>,
T: One,
sourceimpl<T, U> Sub<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Sub<T, Output = T>,
impl<T, U> Sub<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: Sub<T, Output = T>,
sourceimpl<T, U> SubAssign<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: SubAssign<T>,
impl<T, U> SubAssign<Offset<T, U>> for Address<T, U> where
Offset<usize, ()>: Into<Offset<T, ()>>,
T: Mul<T, Output = T>,
T: SubAssign<T>,
sourcefn sub_assign(&mut self, rhs: Offset<T, U>)
fn sub_assign(&mut self, rhs: Offset<T, U>)
Performs the -=
operation. Read more
impl<T: Copy, U: Copy> Copy for Address<T, U>
impl<T: Eq, U> Eq for Address<T, U>
Auto Trait Implementations
impl<T, U> RefUnwindSafe for Address<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Address<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for Address<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for Address<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for Address<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more