pythonize
pythonize copied to clipboard
Support serialising to named mappings
trafficstars
This PR includes four changes:
- Implement
PythonizeListTypeforPyTuple, a small convenience that cannot be achieved outside the crate - Add support for prebuilding mappings during serialisation, which delays the collection of mapping key-value pairs until all are known
- Add support for named mappings during serialisation, which adds a tiny default-implemented helper trait method to pass forward the struct / tuple / enum name to the mapping type
- Allow deserializing an enum from any mapping instead of just dicts
I have found them to be very useful to serialise to and from class-like Python types (e.g. namedtuple which keep more type information around).