From 06caca8b9a9a1df9932c2c82e4ddba80d49edc5c Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sat, 15 Mar 2025 16:29:12 +0800 Subject: bump: update pyo3 dependency to version 0.24.0 and improve module function signature --- Cargo.toml | 2 +- src/lib.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f0c5805..71fe671 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,5 @@ name = "_core" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.19.2", features = ["abi3-py39"] } +pyo3 = { version = "0.24.0", features = ["abi3-py39"] } time = { version = "0.3.39", features = ["formatting", "macros", "local-offset"] } diff --git a/src/lib.rs b/src/lib.rs index 166cb09..8f19266 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,8 +8,11 @@ fn sum_as_string(a: usize, b: usize) -> PyResult { #[pyclass] pub struct Base {} +/// A Python module implemented in Rust. The name of this function must match +/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to +/// import the module. #[pymodule] -fn _core(_py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; m.add_class::()?; Ok(()) -- cgit v1.2.3-70-g09d2