mcarton/rust-derivative

#[derivative(Debug(value = "..."))]

kangalio opened this issue · 1 comments

It would be great to have the option to format a struct field or enum variant as a hardcoded string. For example:

#[derive(Derivative)]
#[derivative(Debug)]
struct Foo {
    #[derivative(Debug(value = "Box<dyn Any>"))]
    data: Box<dyn Any>,
}

// Foo { data: Box<dyn Any> }
println!("{:?}", foo);

another example:

#[derive(Derivative)]
#[derivative(Debug)]
pub enum EffectDescriptor<'cls> {
    Output(#[derivative(Debug(value = "closure[thunk]"))] Box<dyn (Fn() -> TypeBox) + 'cls>),
    UpdateVariable {
        ident: String,
        #[derivative(Debug(value = "closure[thunk]"))]
        value: Box<dyn (Fn() -> TypeBox) + 'cls>,
    },
    PushScope,
    PopScope,
}