#[repr(transparent)]pub struct Pointer<T>(pub Value, _);
Expand description
A handle to a Rust value/reference owned by the OCaml heap.
This should only be used with values allocated with alloc_final
or alloc_custom
,
for abstract pointers see Value::alloc_abstract_ptr
and Value::abstract_ptr_val
Tuple Fields
0: Value
Implementations
sourceimpl<T: Custom> Pointer<T>
impl<T: Custom> Pointer<T>
sourcepub fn alloc_custom(x: T) -> Pointer<T> where
T: Custom,
pub fn alloc_custom(x: T) -> Pointer<T> where
T: Custom,
Allocate a Custom
value
sourceimpl<T> Pointer<T>
impl<T> Pointer<T>
sourcepub fn alloc_final(
x: T,
finalizer: Option<unsafe extern "C" fn(_: Raw)>,
used_max: Option<(usize, usize)>
) -> Pointer<T>
pub fn alloc_final(
x: T,
finalizer: Option<unsafe extern "C" fn(_: Raw)>,
used_max: Option<(usize, usize)>
) -> Pointer<T>
Allocate a new value with an optional custom finalizer and used/max
This calls caml_alloc_final
under-the-hood, which can has less than ideal performance
behavior. In most cases you should prefer Poiner::alloc_custom
when possible.
sourcepub unsafe fn drop_in_place(self)
pub unsafe fn drop_in_place(self)
Drop pointer in place
Safety
This should only be used when you’re in control of the underlying value and want to drop it. It should only be called once.
sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Access the underlying mutable pointer
Trait Implementations
sourceimpl<T> FromValue for Pointer<T>
impl<T> FromValue for Pointer<T>
sourcefn from_value(value: Value) -> Self
fn from_value(value: Value) -> Self
Convert from OCaml value
sourceimpl<T: PartialOrd> PartialOrd<Pointer<T>> for Pointer<T>
impl<T: PartialOrd> PartialOrd<Pointer<T>> for Pointer<T>
sourcefn partial_cmp(&self, other: &Pointer<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Pointer<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Eq> Eq for Pointer<T>
impl<T> StructuralEq for Pointer<T>
impl<T> StructuralPartialEq for Pointer<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Pointer<T> where
T: RefUnwindSafe,
impl<T> !Send for Pointer<T>
impl<T> !Sync for Pointer<T>
impl<T> Unpin for Pointer<T> where
T: Unpin,
impl<T> UnwindSafe for Pointer<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more