pub struct Address<M, T>where
M: Mutability,
T: ?Sized,{ /* private fields */ }
Expand description
A generic non-null pointer with type-system mutability tracking.
§Type Parameters
M
: The mutability permissions of the source pointer.T
: The referent type of the source pointer.
Implementations§
source§impl<M, T> Address<M, T>where
M: Mutability,
impl<M, T> Address<M, T>where
M: Mutability,
source§impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
sourcepub fn new(addr: NonNull<T>) -> Self
pub fn new(addr: NonNull<T>) -> Self
Constructs a new Address
over some pointer value.
You are responsible for selecting the correct Mutability
marker.
sourcepub fn immut(self) -> Address<Const, T>
pub fn immut(self) -> Address<Const, T>
Permanently converts an Address<_>
into an Address<Const>
.
You should generally prefer Address::freeze
.
sourcepub unsafe fn assert_mut(self) -> Address<Mut, T>
pub unsafe fn assert_mut(self) -> Address<Mut, T>
Force an Address<Const>
to be Address<Mut>
.
§Safety
You should only call this on addresses you know to have been created
with Mut
able permissions and previously removed by Address::immut
.
You should prefer using Address::freeze
for temporary, trackable,
immutability constraints instead.
sourcepub fn into_inner(self) -> NonNull<T>
pub fn into_inner(self) -> NonNull<T>
Removes the Address
type marker, returning the original pointer.
source§impl<M, T> Address<M, T>where
M: Mutability,
impl<M, T> Address<M, T>where
M: Mutability,
Port of the pointer inherent methods on Address
es of Sized
types.
sourcepub fn wrapping_offset(self, count: isize) -> Self
pub fn wrapping_offset(self, count: isize) -> Self
Applies <*T>::wrapping_offset
.
sourcepub fn wrapping_add(self, count: usize) -> Self
pub fn wrapping_add(self, count: usize) -> Self
Applies <*T>::wrapping_add
.
sourcepub fn wrapping_sub(self, count: usize) -> Self
pub fn wrapping_sub(self, count: usize) -> Self
Applies <*T>::wrapping_sub
.
sourcepub unsafe fn offset_from(self, origin: Self) -> isize
pub unsafe fn offset_from(self, origin: Self) -> isize
Applies <*T>::offset_from
.
sourcepub unsafe fn read_volatile(self) -> T
pub unsafe fn read_volatile(self) -> T
Applies <*T>::read_volatile
.
sourcepub unsafe fn read_unaligned(self) -> T
pub unsafe fn read_unaligned(self) -> T
Applies <*T>::read_unaligned
.
sourcepub unsafe fn copy_to_nonoverlapping(self, dest: Address<Mut, T>, count: usize)
pub unsafe fn copy_to_nonoverlapping(self, dest: Address<Mut, T>, count: usize)
Applies <*T>::copy_to_nonoverlapping
.
sourcepub fn align_offset(self, align: usize) -> usize
pub fn align_offset(self, align: usize) -> usize
Applies <*T>::align_offset
.
source§impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
Port of the pointer inherent methods on Address
es of any type.
source§impl<T> Address<Mut, T>
impl<T> Address<Mut, T>
Port of pointer inherent methods on mutable Address
es of sized types.
sourcepub unsafe fn copy_from<M2: Mutability>(self, src: Address<M2, T>, count: usize)
pub unsafe fn copy_from<M2: Mutability>(self, src: Address<M2, T>, count: usize)
Applies <*T>::copy_from
.
sourcepub unsafe fn copy_from_nonoverlapping<M2: Mutability>(
self,
src: Address<M2, T>,
count: usize,
)
pub unsafe fn copy_from_nonoverlapping<M2: Mutability>( self, src: Address<M2, T>, count: usize, )
Applies <*T>::copy_from_nonoverlapping
.
sourcepub unsafe fn write_volatile(self, value: T)
pub unsafe fn write_volatile(self, value: T)
Applies <*T>::write_volatile
.
sourcepub unsafe fn write_unaligned(self, value: T)
pub unsafe fn write_unaligned(self, value: T)
Applies <*T>::write_unaligned
.
Trait Implementations§
source§impl<M, T> Ord for Address<M, T>where
M: Mutability,
impl<M, T> Ord for Address<M, T>where
M: Mutability,
source§impl<M1, M2, T1, T2> PartialEq<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
impl<M1, M2, T1, T2> PartialEq<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
source§impl<M1, M2, T1, T2> PartialOrd<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
impl<M1, M2, T1, T2> PartialOrd<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, M, T> Referential<'a> for Address<Frozen<M>, T>where
M: Mutability,
T: 'a + ?Sized,
impl<'a, M, T> Referential<'a> for Address<Frozen<M>, T>where
M: Mutability,
T: 'a + ?Sized,
source§impl<'a, T> SliceReferential<'a> for Address<Const, [T]>where
T: 'a,
impl<'a, T> SliceReferential<'a> for Address<Const, [T]>where
T: 'a,
§type ElementAddr = Address<Const, T>
type ElementAddr = Address<Const, T>
source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
source§impl<'a, M, T> SliceReferential<'a> for Address<Frozen<M>, [T]>where
M: Mutability,
T: 'a,
impl<'a, M, T> SliceReferential<'a> for Address<Frozen<M>, [T]>where
M: Mutability,
T: 'a,
§type ElementAddr = Address<Frozen<M>, T>
type ElementAddr = Address<Frozen<M>, T>
source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
source§impl<'a, T> SliceReferential<'a> for Address<Mut, [T]>where
T: 'a,
impl<'a, T> SliceReferential<'a> for Address<Mut, [T]>where
T: 'a,
§type ElementAddr = Address<Mut, T>
type ElementAddr = Address<Mut, T>
source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
impl<M, T> Copy for Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Eq for Address<M, T>where
M: Mutability,
Auto Trait Implementations§
impl<M, T> Freeze for Address<M, T>
impl<M, T> RefUnwindSafe for Address<M, T>
impl<M, T> !Send for Address<M, T>
impl<M, T> !Sync for Address<M, T>
impl<M, T> Unpin for Address<M, T>
impl<M, T> UnwindSafe for Address<M, T>
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.