diff options
| author | 2024-05-28 00:28:39 +0800 | |
|---|---|---|
| committer | 2024-05-28 00:28:39 +0800 | |
| commit | 28a7b2ecd90e7e67427682a99b8616e13042b4ab (patch) | |
| tree | b97c4784f5b27963aafde21701a135934fef6f5d /src | |
| parent | 2c8f4880eb6ddd0040c20e264dac1aebb018a8b2 (diff) | |
| download | HydroRollCore-28a7b2ecd90e7e67427682a99b8616e13042b4ab.tar.gz HydroRollCore-28a7b2ecd90e7e67427682a99b8616e13042b4ab.zip | |
chore: refresh source tree files
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 36 |
2 files changed, 2 insertions, 37 deletions
@@ -8,7 +8,8 @@ fn sum_as_string(a: usize, b: usize) -> PyResult<String> { /// 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)?)?; Ok(()) -} +}
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 4c28efa..0000000 --- a/src/main.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![allow(unused)] -fn main() { - use pyo3::prelude::*; - - #[pymodule] - fn parent_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - register_child_module(py, m)?; - Ok(()) - } - - fn register_child_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "child_module")?; - child_module.add_function(wrap_pyfunction!(func, child_module)?)?; - parent_module.add_submodule(child_module)?; - Ok(()) - } - - #[pyfunction] - fn func() -> String { - "func".to_string() - } - - Python::with_gil(|py| { - use pyo3::types::IntoPyDict; - use pyo3::wrap_pymodule; - let parent_module = wrap_pymodule!(parent_module)(py); - let ctx = [("parent_module", parent_module)].into_py_dict(py); - - py.run( - "assert parent_module.child_module.func() == 'func'", - None, - Some(&ctx), - ) - .unwrap(); - }) -} |
