ocaml-rs - OCaml extensions in Rust
Note: ocaml-rs
is still experimental, please report any issues on github
ocaml-rs
allows for OCaml extensions to be written directly in Rust with no C stubs. It was forked from raml with the goal of creating a safer, high-level interface.
Documentation
Examples:
use *;
caml!;
caml!
This will take care of all the OCaml garbage collector related bookkeeping (CAMLparam, CAMLlocal and CAMLreturn).
In OCaml the stubs for these functions looks like this:
For more examples see ./example or ocaml-vec.
caml!
macro
The old style caml!
macro has been replaced with a much simpler new format.
Instead of:
caml!;
you can now write:
caml!;
However, when using the type wrappers provided by ocaml-rs
(Array
, List
, Tuple
, Str
, Array1
, ...), caml_local!
is already called internally. This means that the following is valid without having to declare a local value for the result:
caml!;