[−][src]Macro rustypy::unpack_pytuple
Iterates over a a PyTuple and returns a corresponding Rust tuple.
When destructured all inner data is moved out of the tuple which will retain the structure but will point to PyArg::None variant, so is safe to assume the PyTuple as consumed.
Inner containers (ie. PyList<PyArg(T)>
) are converted to the respective Rust analog
(ie. Vec<T>
) and require valid syntax for their respective unpack macro (ie.
unpack_pylist!).
Examples
Unpack a PyTuple which contains a two PyDict types with PyString keys
and values of PyList
// tuple from Python: ({"one": [0, 1, 3]}, {"two": [3, 2, 1]}) let unpacked = unpack_pytuple!(pytuple; ({PyDict{(PyString, PyList{I32 => i64})}}, {PyDict{(PyString, PyList{I32 => i64})}},));