An example of using Rust bindings.
This typically involves some specialized use of Rust's type system.
A C module is contained in the cmodule
directory.
build.rs
compiles this C library and generates Rust bindings from the C header file.
Various Rust binaries in src/bin/
call into this API.
Examples are presented as "tests" in binaries.
Build all the tests:
cargo build --tests
To check the tests without actually compiling:
cargo check --tests
Run all tests using:
cargo test
Run tests in a specific binary using:
cargo test --bin const_char
To see what binaries are available, look for Rust files in src/bin/
or run:
cargo test --bin
- transfer ownership from Rust to C
- transfer ownership from C to Rust
- cause crashes due to lifetime errors