Zngur
Zngur (/zængɑr/) is a C++/Rust interop tool. It tries to expose arbitrary Rust types, methods and functions, while preserving its semantics and ergonomics as much as possible. Using Zngur, you can use arbitrary Rust crates in your C++ code as easily as using it in normal Rust code, and you can write idiomatic Rusty APIs for your C++ library inside C++. See the documentation for more info.
Demo
// Rust values are available in the `::rust` namespace from their absolute path
// in Rust
using Vec = rust::std::vec::Vec<T>;
using Option = rust::std::option::Option<T>;
using BoxDyn = rust::Box<rust::Dyn<T>>;
// You can implement Rust traits for your classes
;
int
Output:
17
s[2] = 7
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', examples/simple/src/generated.rs:186:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
s[4] = Rust panic happened
hello 2 2
hello 5 7
hello 7 14
hello 3 17
34 17
vector iterator has been destructed
[main.cpp:71] t = [
10,
20,
60,
]
See the examples/simple if you want to build and run it.
Installation
The zngur CLI tool can be installed with cargo:
cargo install zngur-cli