Warning
This post was published 67 days ago. The information described in this article may have changed.
I decided to make a library providing a macro to enforce a compile time requirement that a type's generic parameters conform to a certain variance. My plan for doing this was to have the macro generate code which only compiles if the type follows that variance, but I cannot figure out how to do that for invariance. Is making a function which only compiles if a type is invariant with respect to a specific generic parameter even possible? If not, would the best path forward be to insert fields to ensure invariance but continue with the compile-time checking strategy for enforcing covariance and contravariance?
2 posts - 2 participants
🏷️ rust_feed