- Compile the Rust code to a shared library:
rustc --crate-type cdylib lib.rs
the Rust code defines a simple function perform_calculation that multiplies an input integer by 2.
The Rust code is compiled into a shared library, and then the Python script loads and calls this Rust function using ctypes.