MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / func

Function func

extensions/hello/src/hello.rs:20–22  ·  view source on GitHub ↗

The py_fn!()-macro can translate between Python and Rust values, so you can use `&str`, `i32` or `String` in the signature of a function callable from Python. The first argument of type `Python<'p>` is used to indicate that your function may assume that the current thread holds the global interpreter lock. Most functions in the `cpython` crate require that you pass this argument.

(_: Python, a: &str, b: i32)

Source from the content-addressed store, hash-verified

18// function may assume that the current thread holds the global interpreter lock.
19// Most functions in the `cpython` crate require that you pass this argument.
20fn func(_: Python, a: &str, b: i32) -> PyResult<String> {
21 Ok(format!("func({}, {})", a, b))
22}
23
24fn run(py: Python, args: &PyTuple, kwargs: Option<&PyDict>) -> PyResult<PyNone> {
25 println!("Rust says: Hello Python!");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected