@@ -12,11 +12,11 @@ use std::fmt::Debug;
12
12
/// All nodes should have a tag that explains what the node represents
13
13
/// and a pretty string representation of data held by the node.
14
14
pub trait NodeDisplay {
15
- const TAG : & ' static str ;
15
+ fn tag ( & self ) -> & ' static str ;
16
16
fn string_pretty ( & self ) -> String ;
17
17
18
18
fn display ( & self ) -> String {
19
- let tag = console:: style ( Self :: TAG ) . magenta ( ) ;
19
+ let tag = console:: style ( self . tag ( ) ) . magenta ( ) ;
20
20
let content = self . string_pretty ( ) ;
21
21
if content. is_empty ( ) {
22
22
format ! ( "[{tag}]" )
@@ -27,84 +27,108 @@ pub trait NodeDisplay {
27
27
}
28
28
29
29
impl NodeDisplay for TestName {
30
- const TAG : & ' static str = "test name" ;
30
+ fn tag ( & self ) -> & ' static str {
31
+ "test name"
32
+ }
31
33
fn string_pretty ( & self ) -> String {
32
34
self . 0 . clone ( )
33
35
}
34
36
}
35
37
36
38
impl NodeDisplay for ContractName {
37
- const TAG : & ' static str = "contract name" ;
39
+ fn tag ( & self ) -> & ' static str {
40
+ "contract name"
41
+ }
38
42
fn string_pretty ( & self ) -> String {
39
43
self . 0 . to_string ( )
40
44
}
41
45
}
42
46
43
47
impl NodeDisplay for Selector {
44
- const TAG : & ' static str = "selector" ;
48
+ fn tag ( & self ) -> & ' static str {
49
+ "selector"
50
+ }
45
51
fn string_pretty ( & self ) -> String {
46
52
self . 0 . to_string ( )
47
53
}
48
54
}
49
55
50
56
impl NodeDisplay for EntryPointType {
51
- const TAG : & ' static str = "entry point type" ;
57
+ fn tag ( & self ) -> & ' static str {
58
+ "entry point type"
59
+ }
52
60
fn string_pretty ( & self ) -> String {
53
61
string_debug ( self )
54
62
}
55
63
}
56
64
57
65
impl NodeDisplay for TransformedCalldata {
58
- const TAG : & ' static str = "calldata" ;
66
+ fn tag ( & self ) -> & ' static str {
67
+ "calldata"
68
+ }
59
69
fn string_pretty ( & self ) -> String {
60
70
self . 0 . clone ( )
61
71
}
62
72
}
63
73
64
74
impl NodeDisplay for ContractAddress {
65
- const TAG : & ' static str = "contract address" ;
75
+ fn tag ( & self ) -> & ' static str {
76
+ "contract address"
77
+ }
66
78
fn string_pretty ( & self ) -> String {
67
79
string_hex ( self . 0 )
68
80
}
69
81
}
70
82
71
83
impl NodeDisplay for CallerAddress {
72
- const TAG : & ' static str = "caller address" ;
84
+ fn tag ( & self ) -> & ' static str {
85
+ "caller address"
86
+ }
73
87
fn string_pretty ( & self ) -> String {
74
88
string_hex ( self . 0 )
75
89
}
76
90
}
77
91
78
92
impl NodeDisplay for CallType {
79
- const TAG : & ' static str = "call type" ;
93
+ fn tag ( & self ) -> & ' static str {
94
+ "call type"
95
+ }
80
96
fn string_pretty ( & self ) -> String {
81
97
string_debug ( self )
82
98
}
83
99
}
84
100
85
101
impl NodeDisplay for TransformedCallResult {
86
- const TAG : & ' static str = "call result" ;
102
+ fn tag ( & self ) -> & ' static str {
103
+ "call result"
104
+ }
87
105
fn string_pretty ( & self ) -> String {
88
106
self . 0 . clone ( )
89
107
}
90
108
}
91
109
92
110
impl NodeDisplay for FunctionTrace {
93
- const TAG : & ' static str = "function call tree" ;
111
+ fn tag ( & self ) -> & ' static str {
112
+ "function call tree"
113
+ }
94
114
fn string_pretty ( & self ) -> String {
95
115
String :: new ( )
96
116
}
97
117
}
98
118
99
119
impl NodeDisplay for FunctionTraceError {
100
- const TAG : & ' static str = "function trace error" ;
120
+ fn tag ( & self ) -> & ' static str {
121
+ "function trace error"
122
+ }
101
123
fn string_pretty ( & self ) -> String {
102
124
self . to_string ( )
103
125
}
104
126
}
105
127
106
128
impl NodeDisplay for FunctionNode {
107
- const TAG : & ' static str = "non inlined" ;
129
+ fn tag ( & self ) -> & ' static str {
130
+ "non inlined"
131
+ }
108
132
fn string_pretty ( & self ) -> String {
109
133
self . value . function_name ( ) . to_string ( )
110
134
}
0 commit comments