@Alex Crichton is there any deep reason why the pretty-printing of backtraces is an
impl Debug, not an
impl Display? If you hand't told me, I'd never even have looked at this ins earch for pretty-printing.
@RalfJ oh that's in theory a conventions thing where
Display is intended for lossless formatting whereas
Debug is "programmer output in any way possible". I didn't put a lot of effort in making it entirely lossless, but tbh that should probably be
Display as well as
Debug for that type
I always thought
Debug was meant to be lossless, as in "can ideally be parsed back by the compiler"?
Display is "pretty"
At least for libstd it's different
Debug doesn't really mean anything, but
Display is lossless (and parseable if possible) and pretty-ish
that doesn't apply to
String, for example.
Debug is what you can parse (it escapes quotes and things),
Display is just the raw string and not very suited for parsing
@RalfJ for strings the
Display is what you parse (it's just the raw bytes) whereas
Debug is intended to show you any escapes and other tricky chars, if present
hm. to me this quite clearly sounds like
Debug is "more lossless"...
String::from(Display::fmt(&String)) is I believe guaranteed to produce the same string whereas that's (obviously) not true for the debug impl
sure, but the debug output I can copy-paste into a
.rs file and it'll parse the right way
and that's also true for the derived
Debug for enums and structs, and the one for tuples
that's why I thought of it more lossless. I don't know any example where
Debug shows less information that
Display, which is what I would take as a witness for
Display being the more lossless trait
(this obviously doesn't matter very much, I am just curious how we arrived at seemingly contradictory mental models for these traits^^)