#[staticmethod]
in subclass
#2978
-
This library is amazing in terms of usability, api is very intuitive! However I stumbled upon an unexpected problem. Consider the following code: #[pyclass(subclass)]
pub struct Seed(...);
#[pyclass(extends = Seed)]
pub struct Bip39Seed;
#[pymethods]
impl Bip39Seed {
#[staticmethod]
fn generate() -> PyClassInitializer<Self> {
...
PyClassInitializer::from(seed).add_subclass(Self)
}
} There I'm trying to create a subclass with a static method. However, for the result type it expects something to be casted to
Changing result type to What is a recommended way to resolve this issue? (It seems that |
Beta Was this translation helpful? Give feedback.
Answered by
davidhewitt
Feb 22, 2023
Replies: 1 comment
-
Try #[staticmethod]
fn generate(py: Python) -> PyResult<Py<Self>> {
...
Py::new(py, PyClassInitializer::from(seed).add_subclass(Self))
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Rexagon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try