rust-cpython
rust-cpython copied to clipboard
Flexible parameter lists
Add support for:
- [x] Optional parameters
- [ ]
*args - [ ]
**kwargs
Did you had the time to implement this? The documentation say so, and parameters with or without explicit type works.
But trying to use default values gives me errors about unexpected value:
#[macro_use] extern crate cpython;
use cpython::{Python, PyResult};
py_class!(class MyType |py| {
data number: i32;
def __new__(_cls, arg: i32) -> PyResult<MyType> {
MyType::create_instance(py, arg)
}
def foo(&self, a, b: i32 = 8) -> PyResult<PyObject> {
// ===> Error: no rules expected the token `8`at line 62 col 44 in <cpython macros>
println!("{} {}", a, b);
Ok(py.None())
}
});
I tried to read the code to see where this could come from, but my macro-fu is not that good ...