slotmap
slotmap copied to clipboard
Serialization Issue with Unit Types in SlotMap<ID, ()>
First of all, thank you for maintaining the slotmap crate.
I'm currently using SlotMap
with various generic types (VertData
, FaceData
, EdgeData
) to manage graph data in my application:
SlotMap<VertID, VertData>
SlotMap<FaceID, FaceData>
SlotMap<EdgeID, EdgeData>
Occasionally, I use unit types for certain slot maps when no specific data needs to be stored (i.e., SlotMap<EdgeID, ()>
). However, I've encountered serialization and deserialization issues when using unit types.
Issue
When attempting to serialize and deserialize a SlotMap<ID, ()>
, it results in an error: "inconsistent occupation in Slot".
This seems to be triggered by the serialization behavior of the unit type ()
, which Serde serializes as "null"
and then deserializes as None
:
if occupied ^ serde_slot.value.is_some() {
return Err(de::Error::custom("inconsistent occupation in Slot"));
}
Is this expected behavior?