No, this is not supported by the safe type. We would need numeric type literals, such as the recently added GHC.
However, you can use Rust macros. Using a macro, you can create βpatternsβ that are parameterized over arbitrary expressions, including constants that let you do what you want here. Please note that you can find errors and limitations in the macro system if you try this at the moment.
Patrick walton
source share