From 09413f06949b421a1c5b0cc05d70d84b184d3397 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Wed, 5 Jun 2024 04:06:00 +0800 Subject: feat(rust): wrap_pyfunction "process_rule_pack" in libcore module --- src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 213d20e..9d2c8e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,16 @@ use pyo3::prelude::*; +use pyo3::wrap_pyfunction; -/// Formats the sum of two numbers as string. #[pyfunction] -fn sum_as_string(a: usize, b: usize) -> PyResult { - Ok((a + b).to_string()) +fn process_rule_pack(rule_pack: &str) -> PyResult { + // 处理规则包的逻辑 + Ok(format!("Processed rule pack: {}", rule_pack)) } /// A Python module implemented in Rust. #[pymodule] #[pyo3(name = "libcore")] -fn corelib(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; +fn libcore(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(process_rule_pack, m)?)?; Ok(()) } \ No newline at end of file -- cgit v1.2.3-70-g09d2