#[repr(transparent)]pub struct Pointer<'a, 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<'a, T> Pointer<'a, T>
impl<'a, T> Pointer<'a, T>
sourcepub fn alloc_final(
x: T,
finalizer: Option<unsafe extern "C" fn(_: Raw)>,
used_max: Option<(usize, usize)>
) -> Pointer<'a, T>
pub fn alloc_final(
x: T,
finalizer: Option<unsafe extern "C" fn(_: Raw)>,
used_max: Option<(usize, usize)>
) -> Pointer<'a, 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 fn alloc_custom(x: T) -> Pointer<'a, T> where
T: Custom,
pub fn alloc_custom(x: T) -> Pointer<'a, T> where
T: Custom,
Allocate a Custom
value
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<'a, T> FromValue<'a> for Pointer<'a, T>
impl<'a, T> FromValue<'a> for Pointer<'a, T>
sourcefn from_value(value: Value) -> Self
fn from_value(value: Value) -> Self
Convert from OCaml value
sourceimpl<'a, T> IntoValue for Pointer<'a, T>
impl<'a, T> IntoValue for Pointer<'a, T>
sourcefn into_value(self, _rt: &Runtime) -> Value
fn into_value(self, _rt: &Runtime) -> Value
Convert to OCaml value
impl<'a, T> StructuralPartialEq for Pointer<'a, T>
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Pointer<'a, T> where
T: RefUnwindSafe,
impl<'a, T> !Send for Pointer<'a, T>
impl<'a, T> !Sync for Pointer<'a, T>
impl<'a, T> Unpin for Pointer<'a, T>
impl<'a, T> UnwindSafe for Pointer<'a, T> where
T: RefUnwindSafe,
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more