pub struct Ptr<T> { /* private fields */ }
Expand description
Convenience type for holding value of *mut T
Mostly just a projection of NonNull<T>
functionality
Implementations§
source§impl<T> Ptr<T>
impl<T> Ptr<T>
sourcepub fn new(p: NonNull<T>) -> Ptr<T>
pub fn new(p: NonNull<T>) -> Ptr<T>
Wraps a valid NonNull<T>
NonNull<T>
: https://doc.rust-lang.org/nightly/core/ptr/struct.NonNull.html
sourcepub fn with_checked(p: *mut T) -> Option<Ptr<T>>
pub fn with_checked(p: *mut T) -> Option<Ptr<T>>
Checks a *mut T
for null and wraps it up for easier handling.
sourcepub unsafe fn as_ref(&self) -> &T
pub unsafe fn as_ref(&self) -> &T
Get inner reference
Safety
The underlying .as_ref
call is unsafe so this is unsafe as well,
in order to propagate the unsafety invariant forward.
The lifetime of the provided reference is tied to self.
If you need an unbound lifetime, use &*my_ptr.as_ptr()
instead.
Trait Implementations§
source§impl<T> From<NonNull<T>> for Ptr<T>
impl<T> From<NonNull<T>> for Ptr<T>
source§fn from(nn: NonNull<T>) -> Self
fn from(nn: NonNull<T>) -> Self
Free, zero-allocation conversion from NonNull<T>
source§impl<T: PartialOrd> PartialOrd<Ptr<T>> for Ptr<T>
impl<T: PartialOrd> PartialOrd<Ptr<T>> for Ptr<T>
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 TryConvert<Ptr<IDispatch>, ElementError> for *mut IDispatch
impl TryConvert<Ptr<IDispatch>, ElementError> for *mut IDispatch
source§fn try_convert(p: Ptr<IDispatch>) -> Result<Self, ElementError>
fn try_convert(p: Ptr<IDispatch>) -> Result<Self, ElementError>
Unwraps the Ptr with [as_ptr()
]
source§impl TryConvert<Ptr<IUnknown>, ElementError> for *mut IUnknown
impl TryConvert<Ptr<IUnknown>, ElementError> for *mut IUnknown
source§fn try_convert(p: Ptr<IUnknown>) -> Result<Self, ElementError>
fn try_convert(p: Ptr<IUnknown>) -> Result<Self, ElementError>
Unwraps the Ptr with [as_ptr()
]
source§impl<D, T> TryConvert<Ptr<VARIANT>, ElementError> for Variant<D, T>where
D: VariantExt<T>,
impl<D, T> TryConvert<Ptr<VARIANT>, ElementError> for Variant<D, T>where
D: VariantExt<T>,
source§fn try_convert(ptr: Ptr<VARIANT>) -> Result<Self, ElementError>
fn try_convert(ptr: Ptr<VARIANT>) -> Result<Self, ElementError>
Converts a Ptr<VARIANT>
to a Variant<D, T>
where D: VariantExt<T>
source§impl<D, T> TryConvert<Ptr<VARIANT>, FromVariantError> for Variant<D, T>where
D: VariantExt<T>,
impl<D, T> TryConvert<Ptr<VARIANT>, FromVariantError> for Variant<D, T>where
D: VariantExt<T>,
source§fn try_convert(ptr: Ptr<VARIANT>) -> Result<Self, FromVariantError>
fn try_convert(ptr: Ptr<VARIANT>) -> Result<Self, FromVariantError>
Converts a Ptr<VARIANT>
to a Variant<D, T>
where D: VariantExt<T>
source§impl<D, T> TryConvert<Variant<D, T>, ElementError> for Ptr<VARIANT>where
D: VariantExt<T>,
impl<D, T> TryConvert<Variant<D, T>, ElementError> for Ptr<VARIANT>where
D: VariantExt<T>,
source§fn try_convert(v: Variant<D, T>) -> Result<Self, ElementError>
fn try_convert(v: Variant<D, T>) -> Result<Self, ElementError>
Converts a Variant<D, T>
to a Ptr<VARIANT>
where D: VariantExt<T>
This converts the value inside Variant into a Ptr
source§impl<D, T> TryConvert<Variant<D, T>, IntoVariantError> for Ptr<VARIANT>where
D: VariantExt<T>,
impl<D, T> TryConvert<Variant<D, T>, IntoVariantError> for Ptr<VARIANT>where
D: VariantExt<T>,
source§fn try_convert(v: Variant<D, T>) -> Result<Self, IntoVariantError>
fn try_convert(v: Variant<D, T>) -> Result<Self, IntoVariantError>
Converts a Variant<D, T>
to a Ptr<VARIANT>
where D: VariantExt<T>
This converts the value inside Variant into a Ptr
impl<T: Copy> Copy for Ptr<T>
impl<T: Eq> Eq for Ptr<T>
impl SafeArrayElement for Ptr<IDispatch>
SafeArrayElementimpl for ['Ptr<IDispatch>']. This allows it to be converted into SAFEARRAY with vt =
VT_DISPATCH. This overrides the default impl of
from_safearrayand
into_safearray` because *mut IDispatch doesn’t need
an additional indirection to be put into a SAFEARRAY.
impl SafeArrayElement for Ptr<IUnknown>
SafeArrayElementimpl for ['Ptr<IUnknown>']. This allows it to be converted into SAFEARRAY with vt =
VT_UNKNOWN. This overrides the default impl of
from_safearrayand
into_safearray` because *mut IUnknown doesn’t need
an additional indirection to be put into a SAFEARRAY.