Yes, that's the entire point of parametric polymorphism. You are only allowed to use traits which are explicitly declared. This removes many bad surprises and makes the code much more easier to read, write, and maintain – in particular, one can be sure that once generic code type checks, it will compile and run correctly for all allowed instantiations. Let's not go back to C++ templates where this is not true, a major source of pain.
You should be adding those
impls upfront. It's good practice anyway – after all, you might definitely not be the only one who will ever need to debug code using your types. Especially if those are public (but even if they are private, collaborators etc. may also need to interact with them).
And if there are non-
Debug-able types, how do you think implicit derive should/could solve the problem? It pretty much can't. Unless the answer is "it should magically skip non-Debug fields/variants", which I hope it isn't, because that would entangle macro expansion with type checking badly.
Exactly. And that's a good thing, not a problem. A feature, not a bug. That is type checking in action.
Complaining about this is akin to complaining that you can't arbitrarily mix types around operators or that you can't put heterogeneous types into a
Vec. It just doesn't make sense to allow this kind of behavior in a statically-typed language.
Please, let's just type those tiny
#[derive] annotations. Make it part of your muscle memory, it's worth it.
It's not the only trait you'll want to derive anyway. I hope. Because there are many more which should be derived for interoperability, eg.
Hash, and so forth.
I don't think making these all magical(ly special) would be a good idea either – but why would they be different in this regard from
Furthermore, this is not the strongest argument by any means, but seeing which types implement which traits is very valuable. It saves you from having to constantly open the documentation of a type while reading the code. It's a nice little reminder about the capabilities of the type, it would be very annoying to give it up.