Skip to content

Instantly share code, notes, and snippets.

@dedSyn4ps3
Created February 10, 2024 00:58
Show Gist options
  • Save dedSyn4ps3/f45a600fa50e099264b7a4a97f542c41 to your computer and use it in GitHub Desktop.
Save dedSyn4ps3/f45a600fa50e099264b7a4a97f542c41 to your computer and use it in GitHub Desktop.
/// Says hello.
#[pyfunction]
fn say_hello(name: &str) {
println!("Hello there {name}!");
}
/// Runs several test loops
#[pyfunction]
fn run_loops() {
logger::info("Running test loops...");
let mut _count: u32 = 0;
for _ in 0..1000 {
for _ in 0..100 {
_count += 1;
}
}
print!("\n");
logger::debug("Process Finished");
}
#[pymodule]
fn rusty_python(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
m.add_function(wrap_pyfunction!(say_hello, m)?)?;
m.add_function(wrap_pyfunction!(run_loops, m)?)?;
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment