From f7516e5c1ac797cc9d980c17c8522c5f647ddc99 Mon Sep 17 00:00:00 2001 From: ksew1 Date: Wed, 13 Aug 2025 12:55:50 +0200 Subject: [PATCH] Change `NodeDisplay` `const TAG` to `fn tag(&self)` It will be useful in next PRs commit-id:76f269b5 --- crates/debugging/src/tree/ui/display.rs | 52 ++++++++++++++++++------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/crates/debugging/src/tree/ui/display.rs b/crates/debugging/src/tree/ui/display.rs index 0447bf39f1..f58277cbaa 100644 --- a/crates/debugging/src/tree/ui/display.rs +++ b/crates/debugging/src/tree/ui/display.rs @@ -12,11 +12,11 @@ use std::fmt::Debug; /// All nodes should have a tag that explains what the node represents /// and a pretty string representation of data held by the node. pub trait NodeDisplay { - const TAG: &'static str; + fn tag(&self) -> &'static str; fn string_pretty(&self) -> String; fn display(&self) -> String { - let tag = console::style(Self::TAG).magenta(); + let tag = console::style(self.tag()).magenta(); let content = self.string_pretty(); if content.is_empty() { format!("[{tag}]") @@ -27,84 +27,108 @@ pub trait NodeDisplay { } impl NodeDisplay for TestName { - const TAG: &'static str = "test name"; + fn tag(&self) -> &'static str { + "test name" + } fn string_pretty(&self) -> String { self.0.clone() } } impl NodeDisplay for ContractName { - const TAG: &'static str = "contract name"; + fn tag(&self) -> &'static str { + "contract name" + } fn string_pretty(&self) -> String { self.0.to_string() } } impl NodeDisplay for Selector { - const TAG: &'static str = "selector"; + fn tag(&self) -> &'static str { + "selector" + } fn string_pretty(&self) -> String { self.0.to_string() } } impl NodeDisplay for EntryPointType { - const TAG: &'static str = "entry point type"; + fn tag(&self) -> &'static str { + "entry point type" + } fn string_pretty(&self) -> String { string_debug(self) } } impl NodeDisplay for TransformedCalldata { - const TAG: &'static str = "calldata"; + fn tag(&self) -> &'static str { + "calldata" + } fn string_pretty(&self) -> String { self.0.clone() } } impl NodeDisplay for ContractAddress { - const TAG: &'static str = "contract address"; + fn tag(&self) -> &'static str { + "contract address" + } fn string_pretty(&self) -> String { string_hex(self.0) } } impl NodeDisplay for CallerAddress { - const TAG: &'static str = "caller address"; + fn tag(&self) -> &'static str { + "caller address" + } fn string_pretty(&self) -> String { string_hex(self.0) } } impl NodeDisplay for CallType { - const TAG: &'static str = "call type"; + fn tag(&self) -> &'static str { + "call type" + } fn string_pretty(&self) -> String { string_debug(self) } } impl NodeDisplay for TransformedCallResult { - const TAG: &'static str = "call result"; + fn tag(&self) -> &'static str { + "call result" + } fn string_pretty(&self) -> String { self.0.clone() } } impl NodeDisplay for FunctionTrace { - const TAG: &'static str = "function call tree"; + fn tag(&self) -> &'static str { + "function call tree" + } fn string_pretty(&self) -> String { String::new() } } impl NodeDisplay for FunctionTraceError { - const TAG: &'static str = "function trace error"; + fn tag(&self) -> &'static str { + "function trace error" + } fn string_pretty(&self) -> String { self.to_string() } } impl NodeDisplay for FunctionNode { - const TAG: &'static str = "non inlined"; + fn tag(&self) -> &'static str { + "non inlined" + } fn string_pretty(&self) -> String { self.value.function_name().to_string() }