Renaming an instance method #2870
-
Hi all, hopefully short question here. I am trying to simplify some PyO3 wrappers, and was wondering if I could create separate implementation blocks for my python and javascript (wasm) bindings, instead of different wrapper structs. However, this could theoretically result in some name collisions, so I was hoping to rename the method names to impl MyStuct {
pub fn reset(args) {}
}
#[cfg(feature = "jsbindings")]
impl MyStruct {
#[wasm_bindgen(js_name = reset)]
pub fn reset_javascript(args) {
self.reset(args)
}
} Is there an equivalent way to rename the python method name to have roughly similar implementations? I didn't see it in the documentation, if it does. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You're probably looking for `#[pyo3(name = "...")] option: #[cfg(feature = "pyo3")]
#[pymethods]
impl MyStruct {
#[pyo3(name = "reset")]
pub fn reset_py(args) {
self.reset(args)
}
} |
Beta Was this translation helpful? Give feedback.
You're probably looking for `#[pyo3(name = "...")] option: