To prevent an XY problem, here's my initial problem:
I have a type T, and want to preform an action based on its type. I learned the best way to do this is with a trait and different impls for the different types, so I did that:
You are not checking that, though – you are creating a blanket impl.
But if you only need the special case for u8, and you can tolerate restricting the set of types to 'static (i.e., owned) ones, then you can use the type ID to check for u8 inside the blanket impl (Playground).
You can do this on nightly but I really wouldn't recommend it. Specialization is something many people on this forum want. But the consensus seems to be that it won't be coming to stable Rust any time soon. The current nightly specialization feature is unsound. In the example I use the min_specialization feature instead, which is sound AFAIK: