I want to use a witness type to enforce invariants of my code, so I'd like to be able to write a function that creates an object with a type in it that cannot match any other type, including the output of the same function called another time.
I'm Haskell I could do this by encapsulating the output in a GADT. Can something like this be done with rust?
The goal here is to create a safe array type with an associated index type, such that the compiler can ensure that you will never encounter an out of bounds error.