File tree 1 file changed +17
-15
lines changed
1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ pub(crate) fn run(opt: OptExport, shell: &mut Shell) -> anyhow::Result<()> {
43
43
let syn:: File { items, .. } =
44
44
syn:: parse_file ( & code) . with_context ( || format ! ( "`{}` is broken" , src_path. display( ) ) ) ?;
45
45
46
- let mut acc = "" . to_owned ( ) ;
46
+ let mut acc = vec ! [ "" . to_owned( ) , "" . to_owned ( ) ] ;
47
47
48
48
for item in items {
49
49
match item {
@@ -55,6 +55,7 @@ pub(crate) fn run(opt: OptExport, shell: &mut Shell) -> anyhow::Result<()> {
55
55
semi : Some ( _) ,
56
56
..
57
57
} ) => {
58
+ let acc = & mut acc[ 1 ] ;
58
59
let path = src_path
59
60
. with_file_name ( ident. to_string ( ) )
60
61
. with_extension ( "rs" ) ;
@@ -75,32 +76,33 @@ pub(crate) fn run(opt: OptExport, shell: &mut Shell) -> anyhow::Result<()> {
75
76
} ) ;
76
77
77
78
for attr in attrs {
78
- acc += & attr. to_token_stream ( ) . to_string ( ) ;
79
- acc += "\n " ;
79
+ * acc += & attr. to_token_stream ( ) . to_string ( ) ;
80
+ * acc += "\n " ;
80
81
}
81
- acc += & vis. to_token_stream ( ) . to_string ( ) ;
82
- acc += " mod " ;
83
- acc += & ident. to_string ( ) ;
84
- acc += " {\n " ;
82
+ * acc += & vis. to_token_stream ( ) . to_string ( ) ;
83
+ * acc += " mod " ;
84
+ * acc += & ident. to_string ( ) ;
85
+ * acc += " {\n " ;
85
86
if is_safe_to_indent {
86
87
for line in content. lines ( ) {
87
- acc += " " ;
88
- acc += line;
89
- acc += "\n " ;
88
+ * acc += " " ;
89
+ * acc += line;
90
+ * acc += "\n " ;
90
91
}
91
92
} else {
92
- acc += & content;
93
+ * acc += & content;
93
94
}
94
- acc += "}\n " ;
95
+ * acc += "}\n " ;
95
96
}
96
97
item => {
97
- acc += & item. to_token_stream ( ) . to_string ( ) ;
98
- acc += "\n " ;
98
+ let acc = & mut acc[ 0 ] ;
99
+ * acc += & item. to_token_stream ( ) . to_string ( ) ;
100
+ * acc += "\n " ;
99
101
}
100
102
}
101
103
}
102
104
103
- acc = rustfmt ( & acc) ?;
105
+ let acc = rustfmt ( & acc. join ( " \n " ) ) ?;
104
106
105
107
shell. status (
106
108
"Expanded" ,
You can’t perform that action at this time.
0 commit comments