rust-derivative icon indicating copy to clipboard operation
rust-derivative copied to clipboard

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

Open kangalio opened this issue 3 years ago • 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);

kangalio avatar May 26 '22 19:05 kangalio

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,
}

KisaragiEffective avatar Mar 06 '23 19:03 KisaragiEffective