This is an example about how to use pyo3 library. We can call rust functions in python scripts.
In src/function.rs, we define two function add and sum_as_string.
In src/bin/function_test.rs, we test two functions.
In src/lib.rs, we define the interface for python and rust.
In src/python/call_test.py, we show how to use python to call rust functions.
- build the rust project and generate library
cargo build --release
- go to src/python directory
python call_test.py