Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahrefs/rust-ocaml-derive
https://github.com/ahrefs/rust-ocaml-derive
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ahrefs/rust-ocaml-derive
- Owner: ahrefs
- License: mit
- Created: 2018-03-06T10:41:01.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-12T14:19:59.000Z (almost 4 years ago)
- Last Synced: 2024-10-14T11:36:04.761Z (3 months ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 61
- Watchers: 33
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# derive-ocaml - Custom derive and procedural macros for easier ocaml <-> rust FFI
*WARNING* this crate is very experimental
derive-ocaml is based on top of [ocaml-rs](https://github.com/zshipko/ocaml-rs) and adds a custom derive macro for `FromValue` and `ToValue`.
The macro supports structs, enums, and unboxed float records.On top of that it implements a nightly only procedural macro `ocaml-ffi` to ease the boilerplate of writing stubs functions.
```
#[derive(Debug, Default, ToValue, FromValue)]
#[ocaml(floats_array)]
pub struct Vec3 {
x: f32,
y: f32,
z: f32,
}#[ocaml_ffi]
pub fn rust_add_vecs(l: Vec3, r: Vec3) -> Vec3 {
l + r
}
```see `src/example/src/lib.rs` and `src/example/src/stubs.ml` for example