pub struct PackedRef<'a, T, C: PtrCfg, D: Packable>(/* private fields */);Expand description
A type safe reference to a packed pointer.
Equivalent to &T where T is the type of the pointer.
Implementations§
Source§impl<'a, T, C: PtrCfg, D: Packable> PackedRef<'a, T, C, D>
impl<'a, T, C: PtrCfg, D: Packable> PackedRef<'a, T, C, D>
Sourcepub fn new(ptr: &'a T, data: D, cfg: C) -> Result<Self, PackedPtrError>
pub fn new(ptr: &'a T, data: D, cfg: C) -> Result<Self, PackedPtrError>
Creates a new PackedRef from a reference and some data.
§Errors
PackedPtrError::DataOverflowif the data is too large to fit in the pointer.PackedPtrError::UnsafeConfigif the pointer is not compatible with the configuration.
Sourcepub unsafe fn new_unchecked(ptr: &'a T, data: D) -> Self
pub unsafe fn new_unchecked(ptr: &'a T, data: D) -> Self
Creates a new PackedRef from a reference and some data without performing any safety
checks.
§Safety
This function is unsafe because the caller assumes the responsibility of ensuring that the
provided ptr and data are valid and that they are compatible with the configuration.
References are always aligned, therefore ptr should always be valid, but if the ptr of
the system is incompatible with the configuration, then the reference will be corrupted,
resulting in UB.
Also, if the data is too big to fit in the pointer, undefined behavior may occur.
§Arguments
ptr: A reference to aTdata: The data to be packed into the pointer.
§Returns
A new PackedRef with the given ptr and data.
Trait Implementations§
impl<T, C: PtrCfg, D: Packable> Copy for PackedRef<'_, T, C, D>
Auto Trait Implementations§
impl<'a, T, C, D> Freeze for PackedRef<'a, T, C, D>
impl<'a, T, C, D> RefUnwindSafe for PackedRef<'a, T, C, D>
impl<'a, T, C, D> !Send for PackedRef<'a, T, C, D>
impl<'a, T, C, D> !Sync for PackedRef<'a, T, C, D>
impl<'a, T, C, D> Unpin for PackedRef<'a, T, C, D>
impl<'a, T, C, D> UnwindSafe for PackedRef<'a, T, C, D>
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
Mutably borrows from an owned value. Read more