Is there a zero-sized type that implements Display ?
Some context:
I'm using petgraph for working with a graph with no edges, that is represented as a Graph<Foo, ()>. But since () does not implement Display, i can't use methods that want to display the edges (for example exporting to a .dot file)
I resolved my issue by just creating an empty struct and implementing Display for it, but i wondered if something like this existed in the standard library
I can interpret this question in two ways. Either you are interested in existing types for comparison to reason about whether a Display implementation on a ZST is a reasonable thing in the first place. Answer: Yes, they exist, as shown above. Or you’re asking whether there’s a pre-existing concrete type you can your for your purposes, in which case… well I haven’t fully understood your context yet anyways, but… no, those types that exist in the standard library probably don’t happen to have exactly the Display implementation you’re looking for.
But all of these have their own fixed error messages, as mentioned. Since const generic parameters currently cannot contain strings, if you want a zero-sized Display type with your own custom message, you must create your own.