Replies: 1 comment
-
For constants, probably FromIterator will be the easiest way to build it. https://docs.rs/rustpython-vm/latest/rustpython_vm/function/struct.KwArgs.html#impl-FromIterator%3C(String,+T)%3E-for-KwArgs%3CT%3E let kwargs: KwArgs = [
("a".to_owned(), vm.new_pyobj("v1".to_owned()),
("b".to_owned(), vm.new_pyobj("v2".to_owned()),
].into_iter().collect(); Otherwise, building IndexMap will be also possible. Don't forget to convert String to PyObejctRef.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm stuck on trying to build KwArgs or PyDict to pass to function call. In python module I have
kwargs
are all strings. I try to call it from Rust:config
initially has typeHashMap<String, String>
, though I've tried converting it intoIndexMap
to then build KwArgs from it. The closest I've got isThe problem above is that
KwArgs::new(...)
expectsIndexMap<String, PyObjectRef>
and after reading docs I'm still not sure how to achieve this.Beta Was this translation helpful? Give feedback.
All reactions