Rationale about not impl Display for unit type ()

And consider in particular the use case of an error value. (() also doesn't implement std::error::Error, but let's ignore that). What should the text be even in that case?

It can't be the empty string, because then programs would print messages like

Error:

which aren't very friendly. It could be something like “no further information is available”, but then the standard library is making a specific arbitrary choice of wording that might not make sense for other applications.

As I see it, Display should be implemented for types which have a single obvious choice of string representation. ("Obvious" in that there can be others; for example, numbers can be printed in many bases but the world has standardized on base 10.) () does not have such a single choice; the correct representation of it is context-dependent.

7 Likes