File tree Expand file tree Collapse file tree 3 files changed +19
-10
lines changed
Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,22 @@ pub struct Binary {
1313#[ allow( clippy:: min_ident_chars) ]
1414impl fmt:: Display for Binary {
1515 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
16- write ! (
17- f,
18- "({} {} {})" ,
19- self . arg_l,
20- self . op,
21- repr_option_node( self . arg_r. as_ref( ) )
22- )
16+ if self . op == BinaryOperator :: ArraySubscript {
17+ write ! (
18+ f,
19+ "({}[{}])" ,
20+ self . arg_l,
21+ repr_option_node( self . arg_r. as_ref( ) )
22+ )
23+ } else {
24+ write ! (
25+ f,
26+ "({} {} {})" ,
27+ self . arg_l,
28+ self . op,
29+ repr_option_node( self . arg_r. as_ref( ) )
30+ )
31+ }
2332 }
2433}
2534
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ impl fmt::Display for Literal {
135135 f,
136136 "{}" ,
137137 match self {
138- Self :: Empty => "\u{2205} " . to_owned( ) ,
138+ Self :: Empty => "\u{2205} " . to_owned( ) ,
139139 Self :: String ( val) | Self :: Variable ( val) | Self :: Str ( val) => val. to_string( ) ,
140140 Self :: Char ( val) => val. to_string( ) ,
141141 Self :: Number ( val) => format!( "{val}" ) ,
@@ -146,7 +146,7 @@ impl fmt::Display for Literal {
146146
147147#[ allow( clippy:: borrowed_box) ]
148148fn repr_option_node ( opt : Option < & Box < Node > > ) -> String {
149- opt. map_or_else ( || ' \u{2205}' . to_string ( ) , Box :: < Node > :: to_string)
149+ opt. map_or_else ( || " \u{2205} " . to_owned ( ) , Box :: < Node > :: to_string)
150150}
151151
152152fn repr_vec_node ( vec : & [ Node ] ) -> String {
Original file line number Diff line number Diff line change @@ -212,7 +212,7 @@ impl Node {
212212impl fmt:: Display for Node {
213213 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
214214 match self {
215- Self :: Empty => write ! ( f, "\u{2205} " ) ,
215+ Self :: Empty => write ! ( f, "\u{2205} " ) ,
216216 Self :: Binary ( val) => val. fmt ( f) ,
217217 Self :: FunctionCall ( val) => val. fmt ( f) ,
218218 Self :: Leaf ( val) => val. fmt ( f) ,
You can’t perform that action at this time.
0 commit comments