Skip to content

Instantly share code, notes, and snippets.

@isaacharrisholt
Created May 29, 2023 18:43
Show Gist options
  • Save isaacharrisholt/6ddbd2eeb61389161ef2105246bc8c2c to your computer and use it in GitHub Desktop.
Save isaacharrisholt/6ddbd2eeb61389161ef2105246bc8c2c to your computer and use it in GitHub Desktop.
Default Maturin `lib.rs`
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 fibbers(_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