Skip to main content

BorrowedPtr

Struct BorrowedPtr 

Source
pub struct BorrowedPtr<T: Any> { /* private fields */ }

Implementations§

Source§

impl<T: Any> BorrowedPtr<T>

Source

pub fn from_ref(value: &T) -> Self

Source

pub fn from_mut(value: &mut T) -> Self

Source

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.

Source

pub const fn null() -> Self

Source

pub const fn as_raw(&self) -> *mut T

Source

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.
Source

pub fn is_null(&self) -> bool

Source

pub fn with_ref<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&T) -> Result<R>,

Source

pub fn with_option_ref<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(Option<&T>) -> Result<R>,

Source

pub fn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&T) -> R,

Source

pub fn with_mut<R: Any, F>(&mut self, op: F) -> Result<R>
where F: FnOnce(&mut T) -> Result<R>,

Source

pub fn with_mut_ok<R: Any, F>(&mut self, op: F) -> Result<R>
where F: FnOnce(&mut T) -> R,

Source

pub fn with_clone<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(T) -> Result<R>, T: Clone,

Source

pub fn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(T) -> R, T: Clone,

Source

pub fn with_ptr<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(NonNull<c_void>) -> Result<R>,

Source

pub fn with_ptr_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(NonNull<c_void>) -> R,

Source

pub fn with_ref_ref<R: Any, F, P: Any>( &self, ptr: &BorrowedPtr<P>, op: F, ) -> Result<R>
where F: FnOnce(&T, &P) -> Result<R>,

Source

pub fn with_ref_ref_ref<R: Any, F, P1: Any, P2: Any>( &self, ptr1: &BorrowedPtr<P1>, ptr2: &BorrowedPtr<P2>, op: F, ) -> Result<R>
where F: FnOnce(&T, &P1, &P2) -> Result<R>,

Source

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>
where F: FnOnce(&T, &P1, &P2, &P3) -> Result<R>,

Trait Implementations§

Source§

impl<T: Any> Default for BorrowedPtr<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.