[][src]Struct ocaml_interop::OCaml

pub struct OCaml<'a, T: 'a> { /* fields omitted */ }

Representation of OCaml values.

Implementations

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

pub fn as_ref<'b>(&'b self) -> OCamlRef<'b, T> where
    'a: 'b, 
[src]

Obtains an OCamlRef<T> for this value.

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 to_rust<RustT>(&self) -> RustT where
    RustT: FromOCaml<T>, 
[src]

Converts this OCaml value into a Rust value.

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

pub fn unit() -> Self[src]

Returns a value that represent OCaml's unit value.

impl<T> OCaml<'static, Option<T>>[src]

pub fn none() -> Self[src]

Returns a value that represent OCaml's None value.

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

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

Returns an [u8] reference to the internal bytes of this value.

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

Returns a str reference to the internal bytes of this value.

Panics

Panics if the bytes do not form a valid utf8 string.

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

Returns a str reference to the internal bytes of this value.

Safety

No checks are performed to ensure that the returned value is a valid utf8 string.

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

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

Returns an [u8] reference to the internal bytes of this value.

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

Returns a str reference to the internal bytes of this value.

Panics

Panics if the bytes do not form a valid utf8 string.

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

Returns a str reference to the internal bytes of this value.

Safety

No checks are performed to ensure that the returned value is a valid utf8 string.

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

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

Converts an OCaml int to an i64.

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

Creates an OCaml int from an i64 without checking that it fits in an OCaml fixnum.

Safety

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

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

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 to_bool(&self) -> bool[src]

Converts an OCaml boolean into a Rust boolean.

pub fn of_bool(b: bool) -> OCaml<'static, bool>[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, Err> OCaml<'a, Result<A, Err>>[src]

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

Returns true if this OCaml result value is an OCaml Ok.

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

Returns true if this OCaml result value is an OCaml Error.

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

Converts an OCaml Result<T, E> value into a Rust Result<OCaml<T>, OCaml<E>>.

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

pub fn to_tuple(&self) -> (OCaml<'a, A>, OCaml<'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 to_tuple(&self) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, 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 to_tuple(
    &self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, 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 hd(&self) -> Option<OCaml<'a, A>>[src]

Returns the head of an OCaml list.

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

Returns the tail 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 for OCaml<'a, T>[src]

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

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

type Target = OCamlCell<T>

The resulting type after dereferencing.

Auto Trait Implementations

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

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

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

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

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

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.