pub struct BorrowedPtr<T: Any> { /* private fields */ }Implementations§
Source§impl<T: Any> BorrowedPtr<T>
impl<T: Any> BorrowedPtr<T>
pub fn from_ref(value: &T) -> Self
pub fn from_mut(value: &mut T) -> Self
Sourcepub const unsafe fn from_raw(ptr: *mut T) -> Self
pub const unsafe fn from_raw(ptr: *mut T) -> Self
§Safety
ptr must be either null or point to a valid T for the duration of
any borrowing operations performed through this wrapper.
pub const fn null() -> Self
pub const fn as_raw(&self) -> *mut T
Sourcepub fn erase(&self) -> ErasedBorrowedPtr
pub fn erase(&self) -> ErasedBorrowedPtr
Erase the pointee type while preserving the same borrowed-pointer contract.
The returned ErasedBorrowedPtr points to the same allocation as this
BorrowedPtr<T>, but without the concrete T.
§Invariants
- The erased pointer is valid for at most the same duration as this
BorrowedPtr<T>. - Erasing the type does not extend the lifetime of the underlying value.
- The erased pointer does not carry ownership and must not be used after the original borrowed pointer would no longer be valid.
pub fn is_null(&self) -> bool
pub fn with_ref<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_option_ref<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_mut<R: Any, F>(&mut self, op: F) -> Result<R>
pub fn with_mut_ok<R: Any, F>(&mut self, op: F) -> Result<R>
pub fn with_clone<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_ptr<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_ptr_ok<R: Any, F>(&self, op: F) -> Result<R>
pub fn with_ref_ref<R: Any, F, P: Any>( &self, ptr: &BorrowedPtr<P>, op: F, ) -> Result<R>
pub fn with_ref_ref_ref<R: Any, F, P1: Any, P2: Any>( &self, ptr1: &BorrowedPtr<P1>, ptr2: &BorrowedPtr<P2>, op: F, ) -> Result<R>
pub fn with_ref_ref_ref_ref<R: Any, F, P1: Any, P2: Any, P3: Any>( &self, ptr1: &BorrowedPtr<P1>, ptr2: &BorrowedPtr<P2>, ptr3: &BorrowedPtr<P3>, op: F, ) -> Result<R>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for BorrowedPtr<T>
impl<T> RefUnwindSafe for BorrowedPtr<T>where
T: RefUnwindSafe,
impl<T> !Send for BorrowedPtr<T>
impl<T> !Sync for BorrowedPtr<T>
impl<T> Unpin for BorrowedPtr<T>
impl<T> UnsafeUnpin for BorrowedPtr<T>
impl<T> UnwindSafe for BorrowedPtr<T>where
T: RefUnwindSafe,
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