Struct ocaml::Pointer[][src]

#[repr(transparent)]
pub struct Pointer<'a, T>(pub Value, _);

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

Implementations

impl<'a, T> Pointer<'a, T>[src]

pub fn alloc_final(
    x: T,
    finalizer: Option<unsafe extern "C" fn(_: Raw)>,
    used_max: Option<(usize, usize)>
) -> Pointer<'a, T>
[src]

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.

pub fn alloc_custom(x: T) -> Pointer<'a, T> where
    T: Custom
[src]

Allocate a Custom value

pub unsafe fn drop_in_place(self)[src]

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.

pub fn set(&mut self, x: T)[src]

Replace the inner value with the provided argument

pub fn as_ptr(&self) -> *const T[src]

Access the underlying pointer

pub fn as_mut_ptr(&mut self) -> *mut T[src]

Access the underlying mutable pointer

Trait Implementations

impl<'a, T> AsMut<T> for Pointer<'a, T>[src]

fn as_mut(&mut self) -> &mut T[src]

Performs the conversion.

impl<'a, T> AsRef<T> for Pointer<'a, T>[src]

fn as_ref(&self) -> &T[src]

Performs the conversion.

impl<'a, T: Clone> Clone for Pointer<'a, T>[src]

fn clone(&self) -> Pointer<'a, T>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, T> FromValue<'a> for Pointer<'a, T>[src]

fn from_value(value: Value) -> Self[src]

Convert from OCaml value

impl<'a, T> IntoValue for Pointer<'a, T>[src]

fn into_value(self, _rt: &Runtime) -> Value[src]

Convert to OCaml value

impl<'a, T: PartialEq> PartialEq<Pointer<'a, T>> for Pointer<'a, T>[src]

fn eq(&self, other: &Pointer<'a, T>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Pointer<'a, T>) -> bool[src]

This method tests for !=.

impl<'a, T> StructuralPartialEq for Pointer<'a, T>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.