[−][src]Struct ocaml_interop::OCaml
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.
impl OCaml<'static, ()>
[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 as_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 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]
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 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 + 'a> Clone for OCaml<'a, T>
[src]
impl<'a, T: Copy + 'a> Copy for OCaml<'a, T>
[src]
impl<'a, OCamlT, RustT> ToRust<RustT> for OCaml<'a, OCamlT> where
RustT: FromOCaml<OCamlT>,
[src]
RustT: FromOCaml<OCamlT>,
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for OCaml<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Sync for OCaml<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for OCaml<'a, T>
impl<'a, T> UnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
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>,