Skip to content

Commit f7516e5

Browse files
committed
Change NodeDisplay const TAG to fn tag(&self)
It will be useful in next PRs commit-id:76f269b5
1 parent 4c0173f commit f7516e5

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

crates/debugging/src/tree/ui/display.rs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use std::fmt::Debug;
1212
/// All nodes should have a tag that explains what the node represents
1313
/// and a pretty string representation of data held by the node.
1414
pub trait NodeDisplay {
15-
const TAG: &'static str;
15+
fn tag(&self) -> &'static str;
1616
fn string_pretty(&self) -> String;
1717

1818
fn display(&self) -> String {
19-
let tag = console::style(Self::TAG).magenta();
19+
let tag = console::style(self.tag()).magenta();
2020
let content = self.string_pretty();
2121
if content.is_empty() {
2222
format!("[{tag}]")
@@ -27,84 +27,108 @@ pub trait NodeDisplay {
2727
}
2828

2929
impl NodeDisplay for TestName {
30-
const TAG: &'static str = "test name";
30+
fn tag(&self) -> &'static str {
31+
"test name"
32+
}
3133
fn string_pretty(&self) -> String {
3234
self.0.clone()
3335
}
3436
}
3537

3638
impl NodeDisplay for ContractName {
37-
const TAG: &'static str = "contract name";
39+
fn tag(&self) -> &'static str {
40+
"contract name"
41+
}
3842
fn string_pretty(&self) -> String {
3943
self.0.to_string()
4044
}
4145
}
4246

4347
impl NodeDisplay for Selector {
44-
const TAG: &'static str = "selector";
48+
fn tag(&self) -> &'static str {
49+
"selector"
50+
}
4551
fn string_pretty(&self) -> String {
4652
self.0.to_string()
4753
}
4854
}
4955

5056
impl NodeDisplay for EntryPointType {
51-
const TAG: &'static str = "entry point type";
57+
fn tag(&self) -> &'static str {
58+
"entry point type"
59+
}
5260
fn string_pretty(&self) -> String {
5361
string_debug(self)
5462
}
5563
}
5664

5765
impl NodeDisplay for TransformedCalldata {
58-
const TAG: &'static str = "calldata";
66+
fn tag(&self) -> &'static str {
67+
"calldata"
68+
}
5969
fn string_pretty(&self) -> String {
6070
self.0.clone()
6171
}
6272
}
6373

6474
impl NodeDisplay for ContractAddress {
65-
const TAG: &'static str = "contract address";
75+
fn tag(&self) -> &'static str {
76+
"contract address"
77+
}
6678
fn string_pretty(&self) -> String {
6779
string_hex(self.0)
6880
}
6981
}
7082

7183
impl NodeDisplay for CallerAddress {
72-
const TAG: &'static str = "caller address";
84+
fn tag(&self) -> &'static str {
85+
"caller address"
86+
}
7387
fn string_pretty(&self) -> String {
7488
string_hex(self.0)
7589
}
7690
}
7791

7892
impl NodeDisplay for CallType {
79-
const TAG: &'static str = "call type";
93+
fn tag(&self) -> &'static str {
94+
"call type"
95+
}
8096
fn string_pretty(&self) -> String {
8197
string_debug(self)
8298
}
8399
}
84100

85101
impl NodeDisplay for TransformedCallResult {
86-
const TAG: &'static str = "call result";
102+
fn tag(&self) -> &'static str {
103+
"call result"
104+
}
87105
fn string_pretty(&self) -> String {
88106
self.0.clone()
89107
}
90108
}
91109

92110
impl NodeDisplay for FunctionTrace {
93-
const TAG: &'static str = "function call tree";
111+
fn tag(&self) -> &'static str {
112+
"function call tree"
113+
}
94114
fn string_pretty(&self) -> String {
95115
String::new()
96116
}
97117
}
98118

99119
impl NodeDisplay for FunctionTraceError {
100-
const TAG: &'static str = "function trace error";
120+
fn tag(&self) -> &'static str {
121+
"function trace error"
122+
}
101123
fn string_pretty(&self) -> String {
102124
self.to_string()
103125
}
104126
}
105127

106128
impl NodeDisplay for FunctionNode {
107-
const TAG: &'static str = "non inlined";
129+
fn tag(&self) -> &'static str {
130+
"non inlined"
131+
}
108132
fn string_pretty(&self) -> String {
109133
self.value.function_name().to_string()
110134
}

0 commit comments

Comments
 (0)