linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

[feature request]: bound types on `Debug` #477

Open derekdreery opened 2 years ago

derekdreery commented 2 years ago

It would occasionally help debugging very much if RenderContext, Text, TextLayoutBuilder, TextLayout, Image etc. were all bounded by Debug, so when e.g. you're retaining them in a struct you can just derive(Debug).

cmyr commented 2 years ago

Yes this is reasonable request.

Do we expect these impls to be useful?

In any case I see two options: we can add these bounds to the trait (trait Text: Debug) or we can make this an informal contract for things reexported by piet-common, and just have a test in piet-common that checks that Debug is impl'd for these types, like:

fn check_debug<T: Debug>() {};

#[test]
fn ensure_debug() {
    check_debug::<PietText>();
   // etc
}

I have some sort of emotional preference for not having this be a bound on the traits, but I'm not sure where that comes from honestly.