blee
1
pub enum FnCast {
FnReturnContext(fn(Context) -> Context),
FnReturnJSON(fn(Context) -> Value),
FnContext(fn(Context)),
FnOther(fn(Other)),
FnPush(for<'a> fn(SomeType, &mut Another)),
}
the standard derive macro works for all but FnPush. How do I implement debug here?
H2CO3
2
You can implement Debug
for a wrapper type around fn(SomeType, &mut Another)
, like this:
pub struct DebugFn(pub fn(SomeType, &mut Another));
impl fmt::Debug for DebugFn {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:p}", &self.0)
}
}
1 Like
blee
3
I dont like the indirection... but it works. TY
system
Closed
4
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.