[][src]Struct ocaml_interop::OCaml

#[repr(transparent)]pub struct OCaml<'a, T: 'a> { /* fields omitted */ }

Representation of OCaml values inside ocaml_frame blocks.

Should not be instantiated directly, and will usually be the result of ocaml_alloc! and ocaml_call! expressions, or the input arguments of functions defined inside ocaml_export! blocks.

Implementations

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

pub unsafe fn raw(&self) -> RawOCaml[src]

Gets the raw representation for this value reference (pointer or int).

Safety

The resulting raw pointer will not be tracked, and may become invalid after any call into the OCaml runtime. Great care must be taken when working with these values.

pub fn keep<'gc>(self, gc: &GCFrame<'gc>) -> OCamlRef<'gc, T>[src]

Returns a tracked reference to this value.

This method must be used with values that will be referenced after calls into the OCaml runtime have been made.

impl OCaml<'static, ()>[src]

pub fn unit() -> OCaml<'static, ()>[src]

Returns a value that represent OCaml's unit value.

impl<'a> OCaml<'a, String>[src]

pub unsafe fn as_bytes(&self) -> &'a [u8][src]

pub unsafe fn as_str(&self) -> &'a str[src]

pub unsafe fn as_str_unchecked(&self) -> &'a str[src]

impl<'a> OCaml<'a, OCamlBytes>[src]

pub unsafe fn as_bytes(&self) -> &'a [u8][src]

pub unsafe fn as_str(&self) -> &'a str[src]

pub unsafe fn as_str_unchecked(&self) -> &'a str[src]

impl<'a> OCaml<'a, OCamlInt>[src]

pub fn as_i64(&self) -> i64[src]

Converts an OCaml int to an i64.

pub unsafe fn of_i64(n: i64) -> OCaml<'static, OCamlInt>[src]

Creates an OCaml int from an i64.

Safety

OCaml ints are represented as 63bits + 1bit tag, so when converting from an i64, a bit of precision is lost.

pub fn of_i32(n: i32) -> OCaml<'static, OCamlInt>[src]

Creates an OCaml int from an i32.

impl<'a> OCaml<'a, bool>[src]

pub fn as_bool(self) -> bool[src]

Converts an OCaml boolean into a Rust boolean.

pub fn of_bool(b: bool) -> Self[src]

Creates an OCaml boolean from a Rust boolean.

impl<'a, A> OCaml<'a, Option<A>>[src]

pub fn is_none(&self) -> bool[src]

Returns true if this OCaml option value is an OCaml None.

pub fn is_some(&self) -> bool[src]

Returns true if this OCaml option value is an OCaml Some.

pub fn to_option(&self) -> Option<OCaml<'a, A>>[src]

Converts an OCaml Option<T> value into a Rust Option<OCaml<T>>.

impl<'a, A, B> OCaml<'a, (A, B)>[src]

pub fn fst(&self) -> OCaml<'a, A>[src]

pub fn snd(&self) -> OCaml<'a, B>[src]

impl<'a, A, B, C> OCaml<'a, (A, B, C)>[src]

pub fn fst(&self) -> OCaml<'a, A>[src]

pub fn snd(&self) -> OCaml<'a, B>[src]

pub fn tuple_3(&self) -> OCaml<'a, C>[src]

impl<'a, A, B, C, D> OCaml<'a, (A, B, C, D)>[src]

pub fn fst(&self) -> OCaml<'a, A>[src]

pub fn snd(&self) -> OCaml<'a, B>[src]

pub fn tuple_3(&self) -> OCaml<'a, C>[src]

pub fn tuple_4(&self) -> OCaml<'a, D>[src]

impl<'a, A> OCaml<'a, OCamlList<A>>[src]

pub fn nil() -> Self[src]

Returns an OCaml nil (empty list) value.

pub fn is_empty(&self) -> bool[src]

Returns true if the value is OCaml's nil (empty list).

pub fn tl(&self) -> Option<OCaml<'a, A>>[src]

Returns the tail of an OCaml list.

pub fn hd(&self) -> Option<OCaml<'a, A>>[src]

Returns the head of an OCaml list.

pub fn uncons(&self) -> Option<(OCaml<'a, A>, Self)>[src]

Returns a tuple of the head and tail of an OCaml list.

Trait Implementations

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

impl<'a, T: Copy + 'a> Copy for OCaml<'a, T>[src]

impl<'a, T, U> IntoRust<U> for OCaml<'a, T> where
    U: FromOCaml<T>, 
[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for OCaml<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for OCaml<'a, T> where
    T: Sync

impl<'a, T> Sync for OCaml<'a, T> where
    T: Sync

impl<'a, T> Unpin for OCaml<'a, T>

impl<'a, T> UnwindSafe for OCaml<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.