From 8a8bc2adfb8369c6d0d4115dd13268bf341a0662 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 17 Aug 2021 15:32:12 +0800 Subject: [PATCH] Improve FnPtr debug display. --- src/fn_ptr.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fn_ptr.rs b/src/fn_ptr.rs index 6815ce0c..3b9350cb 100644 --- a/src/fn_ptr.rs +++ b/src/fn_ptr.rs @@ -13,9 +13,19 @@ use std::{ /// A general function pointer, which may carry additional (i.e. curried) argument values /// to be passed onto a function during a call. -#[derive(Debug, Clone, Hash)] +#[derive(Clone, Hash)] pub struct FnPtr(Identifier, StaticVec); +impl fmt::Debug for FnPtr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if !self.is_curried() { + write!(f, "Fn({})", self.fn_name()) + } else { + f.debug_tuple("Fn").field(&self.0).field(&self.1).finish() + } + } +} + impl FnPtr { /// Create a new function pointer. #[inline(always)]