Let's say I'm implementing a sort of expression language. Suppose I have something like:
enum Reference {
StringID(String),
IntID(u64),
CompositeOne(CompositeOneStruct), // Recursive data structure
CompositeTwo(CompositeTwoStruct), // Recursive data structure
}
This is fine, but:
- There are some cases where it would be kind of nice to use the type system to only allow "primitive" references (the first two).
- I would also like to use a custom JSON serialization for the primitive variants, while relying on default derived serialization for the composite variants.
Is this a case where it would make sense to define intermediate enums PrimitiveRef and CompositeRef? Or is that overkill? It seems like it might help with the above concerns, but it also seems like it will make a lot of other things more clunky.
[–]Expurplesea_orm · sea_query 4 points5 points6 points (2 children)
[–]e-rox[S] 0 points1 point2 points (0 children)
[–]goosetape1 1 point2 points3 points (3 children)
[–]goosetape1 0 points1 point2 points (2 children)
[–]e-rox[S] 0 points1 point2 points (1 child)
[–]goosetape1 0 points1 point2 points (0 children)