I have the next error: implementation of 'Debug' is not general enough 'Debug' would have to be implemented for the type for<'r> fn(&'r Vec<Vec<f32>>) -> Vec<f32> ...but 'Debug' is actually implemented for the type 'fn(&'0 Vec<Vec<f32>>) -> Vec<f32>', for some specific lifetime '0 whilst using
where I want to assign default params to each of the rows, thats why I'm using Derivative. However, the error made by default Debug implementation for score_function.
#[derive(Debug)]
struct S {
f: fn(&Vec<Vec<f32>>)
}
I'd be a little surprised if there wasn't an issue already, but didn't find one offhand.
Anyway, derive is limited in other senses too. The workaround is generally to implement it yourself. I'm not sure if derivative would require special steps.
Thanks, but if I implement it by myself, I need to implement it for every field of my struct? Because I have like 20 fields, and my implementation will be like
If it's only this one field preventing the derive, perhaps create a separate type for it (newtype) and impl Debug with a shallow representation, maybe using a string that consists of the field name and its type (i32). This will allow you to derive the parent struct with the many fields that you are describing.
If that's you're manual implementation, sure -- that's basically just an expansion of what the macro does. I meant print something for the value yourself. This works, but may or may not be useful. @EdmundsEcho's recommendation is a good one -- you could store the newtype and derive, or you could have a custom implementation where you pass some "temp" type.