diff options
| author | 2024-06-05 04:06:00 +0800 | |
|---|---|---|
| committer | 2024-06-05 04:06:00 +0800 | |
| commit | 09413f06949b421a1c5b0cc05d70d84b184d3397 (patch) | |
| tree | 7b74bdafac7fb420d73137683209ba7d46acdda2 /src | |
| parent | 28a7b2ecd90e7e67427682a99b8616e13042b4ab (diff) | |
| download | HydroRollCore-09413f06949b421a1c5b0cc05d70d84b184d3397.tar.gz HydroRollCore-09413f06949b421a1c5b0cc05d70d84b184d3397.zip | |
feat(rust): wrap_pyfunction "process_rule_pack" in libcore module
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 11 | ||||
| -rw-r--r-- | src/main.rs | 13 |
2 files changed, 19 insertions, 5 deletions
@@ -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<String> { - Ok((a + b).to_string()) +fn process_rule_pack(rule_pack: &str) -> PyResult<String> { + // 处理规则包的逻辑 + 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 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a855efc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,13 @@ +use lib::process_rule_pack; + +fn main() { + let args: Vec<String> = std::env::args().collect(); + if args.len() < 2 { + eprintln!("Usage: {} <rule_pack>", args[0]); + std::process::exit(1); + } + match process_rule_pack(&args[1]) { + Ok(result) => println!("Result: {}", result), + Err(e) => eprintln!("Error: {}", e), + } +}
\ No newline at end of file |
