[−][src]Struct ocaml_interop::OCaml
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]
'a: 'b,
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]
RustT: FromOCaml<T>,
Converts this OCaml value into a Rust value.
impl OCaml<'static, ()>
[src]
impl<T> OCaml<'static, Option<T>>
[src]
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]
n: i64
) -> Result<OCaml<'static, OCamlInt>, OCamlFixnumConversionError>
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]
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>)
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]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Copy for OCaml<'a, T>
[src]
impl<'a, T> Deref for OCaml<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<'a, T> Send for OCaml<'a, T> where
T: Sync,
[src]
T: Sync,
impl<'a, T> Sync for OCaml<'a, T> where
T: Sync,
[src]
T: Sync,
impl<'a, T> Unpin for OCaml<'a, T>
[src]
impl<'a, T> UnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,