I mean, the function by @DNF here seems pretty much optimal to me? The union splitting mentioned further down is only relevant if you want to eek out the absolute maximum of performance (and wouldn’t be done how you’ve done it in your OP here anyway).
As has been mentioned in your original thread, trying to differentiate structs from Any
is a fools’ errand - there is no semantic difference.