conradludgate / dbg-pls

`Debug` in rust, but only supports valid rust syntax and outputs nicely formatted using pretty-please
36 stars 3 forks source link

Integration with Serde #9

Open amab8901 opened 2 months ago

amab8901 commented 2 months ago

I have a struct containing a serde_json::Value field like this:

use dbg_pls::{color, DebugPls};
use serde_json::Value;

fn main() {
    let expr = Structer::default();
    color!(expr);
}

#[derive(Default, Clone, DebugPls)]
struct Structer {
    pub field1: Value,
    pub field2: u32,
    pub field3: Vec<bool>,
}

Orphan rule doesn't let me apply DebugPls on serde_json::Value. Can you apply it (behind a serde feature)?

I think it's good to also apply std dbg! as a fallback for cases where I wanna use a 3rd party type for which DebugPls hasn't been implemented

conradludgate commented 2 months ago

Sounds reasonable

amab8901 commented 2 months ago

I have an idea! maybe you could use generics in the DebugPls trait, such that it's automatically implemented on every type that implements Debug? That way, we can get around the orphan rule so that DebugPls automatically works whenever Debug works, especially for 3rd party crates