aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2025-03-15 16:29:12 +0800
committerHsiangNianian <i@jyunko.cn>2025-03-15 16:29:12 +0800
commit06caca8b9a9a1df9932c2c82e4ddba80d49edc5c (patch)
tree65d8b00475678e0205801247c32b3c5620b27142
parentde9e8a0c7388bc04acb951a2a687c73adb38e7ff (diff)
downloadconventional_role_play-06caca8b9a9a1df9932c2c82e4ddba80d49edc5c.tar.gz
conventional_role_play-06caca8b9a9a1df9932c2c82e4ddba80d49edc5c.zip
bump: update pyo3 dependency to version 0.24.0 and improve module function signature
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs5
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<String> {
#[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::<Base>()?;
Ok(())