Replies: 2 comments 3 replies
-
|
or an alternative, could we have an extension trait that is implemented for all types that implements Facet with a method say "p()" that casts it to a facet::Value wrapper that implements both Debug and Display, then we could use the rust built in format!, print! etc and get both "Display" and "Debug" for free, something like: // mycrate
use facet-debug.:*;
fn tests() {
let v = MyCustomStructDerivingFacet::new();
let a = format!("short:{}, long multi line: {:?}", v.p(), v.p());
eprintln!("short:{}, long multi line: {:?}", v.p(), v.p());
}That could be really rather nice actually - we could get one "Display" for "free" as a user, but still possible to implement a custom Display on our own type if we want. The one thing that "bothers" is the p() (or whatever, but should be short) -but I see no way around that. If something like this was created (or maybe it exists and i have missed it) the big question i guess would be - what should the default Display show |
Beta Was this translation helpful? Give feedback.
-
|
There should be a way to derive Debug for facet types, which internally will just use facet-pretty to render the output! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
One of the things that facet "promisses" is to avoid implementing e.g. Debug on all types. In practice however I find thats its inconvenient to not do it, If I remove Debug and I want to "debugW using e.g. eprintln!() i often have to go through and add Debug to loats of structs just to print one (that includes others).
I.e. in practice I find myself leaving the derive[Debug] in for those situations.
Should we have a facet-print or somthing that provides the equivalents of format, print, eprint but uses facet to print? (With some smart "selection" such that {} only prints a little and {:?} prints the whole glory facet-pretty?
stuff like eprintln!("{} {} {}", a.pretty(), b.pretty(), c.pretty()) is possible but quickly gets annoying
Beta Was this translation helpful? Give feedback.
All reactions