Skip to content

Instantly share code, notes, and snippets.

@dedSyn4ps3
Created February 10, 2024 00:46
Show Gist options
  • Save dedSyn4ps3/50cd886fa3e12a09c2a85f115b6b0347 to your computer and use it in GitHub Desktop.
Save dedSyn4ps3/50cd886fa3e12a09c2a85f115b6b0347 to your computer and use it in GitHub Desktop.
use pyo3::prelude::*;
/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
/// A Python module implemented in Rust.
#[pymodule]
fn rusty_python(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment