@@ -251,65 +251,64 @@ pub enum AbstractLineToken<'src> {
251251}
252252
253253impl < ' src > AbstractLineToken < ' src > {
254- pub fn into_single_line ( self ) -> Vec < ConcreteLineTokenAndTargets < ' src > > {
254+ pub fn write_single_line ( self , out : & mut Vec < ConcreteLineTokenAndTargets < ' src > > ) {
255255 match self {
256256 Self :: CollapsingNewLine ( heredoc_strings) => {
257- let mut res = Vec :: new ( ) ;
258257 if heredoc_strings. is_some ( ) {
259- res . push ( cltats_hard_newline ( ) ) ;
258+ out . push ( cltats_hard_newline ( ) ) ;
260259 }
261- res. extend ( Self :: shimmy_and_shake_heredocs ( heredoc_strings) ) ;
262- res
260+ Self :: write_heredocs ( heredoc_strings, out) ;
263261 }
264262 Self :: SoftNewline ( heredoc_strings) => {
265- let mut res = vec ! [ ConcreteLineTokenAndTargets :: ConcreteLineToken (
263+ out . push ( ConcreteLineTokenAndTargets :: ConcreteLineToken (
266264 ConcreteLineToken :: Space ,
267- ) ] ;
268- res. extend ( Self :: shimmy_and_shake_heredocs ( heredoc_strings) ) ;
269- res
265+ ) ) ;
266+ Self :: write_heredocs ( heredoc_strings, out) ;
270267 }
271- Self :: SoftIndent { .. } => Vec :: new ( ) ,
268+ Self :: SoftIndent { .. } => { }
272269 Self :: ConcreteLineToken ( clt) => {
273- vec ! [ ConcreteLineTokenAndTargets :: ConcreteLineToken ( clt) ]
270+ out. push ( ConcreteLineTokenAndTargets :: ConcreteLineToken ( clt) ) ;
271+ }
272+ Self :: BreakableEntry ( be) => {
273+ out. push ( ConcreteLineTokenAndTargets :: BreakableEntry ( be) ) ;
274274 }
275- Self :: BreakableEntry ( be) => vec ! [ ConcreteLineTokenAndTargets :: BreakableEntry ( be) ] ,
276275 Self :: BreakableCallChainEntry ( bcce) => {
277- vec ! [ ConcreteLineTokenAndTargets :: BreakableCallChainEntry ( bcce) ]
276+ out . push ( ConcreteLineTokenAndTargets :: BreakableCallChainEntry ( bcce) ) ;
278277 }
279278 }
280279 }
281280
282- pub fn into_multi_line ( self ) -> Vec < ConcreteLineTokenAndTargets < ' src > > {
281+ pub fn write_multi_line ( self , out : & mut Vec < ConcreteLineTokenAndTargets < ' src > > ) {
283282 match self {
284283 Self :: CollapsingNewLine ( heredoc_strings) => {
285- let mut res = vec ! [ cltats_hard_newline( ) ] ;
286- res. extend ( Self :: shimmy_and_shake_heredocs ( heredoc_strings) ) ;
287- res
284+ out. push ( cltats_hard_newline ( ) ) ;
285+ Self :: write_heredocs ( heredoc_strings, out) ;
288286 }
289287 Self :: SoftNewline ( heredoc_strings) => {
290- let mut res = vec ! [ cltats_hard_newline( ) ] ;
291- res. extend ( Self :: shimmy_and_shake_heredocs ( heredoc_strings) ) ;
292- res
288+ out. push ( cltats_hard_newline ( ) ) ;
289+ Self :: write_heredocs ( heredoc_strings, out) ;
293290 }
294291 Self :: SoftIndent { depth } => {
295- vec ! [ ConcreteLineTokenAndTargets :: ConcreteLineToken (
292+ out . push ( ConcreteLineTokenAndTargets :: ConcreteLineToken (
296293 ConcreteLineToken :: Indent { depth } ,
297- ) ]
294+ ) ) ;
298295 }
299296 Self :: ConcreteLineToken ( clt) => {
300- vec ! [ ConcreteLineTokenAndTargets :: ConcreteLineToken ( clt) ]
297+ out. push ( ConcreteLineTokenAndTargets :: ConcreteLineToken ( clt) ) ;
298+ }
299+ Self :: BreakableEntry ( be) => {
300+ out. push ( ConcreteLineTokenAndTargets :: BreakableEntry ( be) ) ;
301301 }
302- Self :: BreakableEntry ( be) => vec ! [ ConcreteLineTokenAndTargets :: BreakableEntry ( be) ] ,
303302 Self :: BreakableCallChainEntry ( bcce) => {
304- vec ! [ ConcreteLineTokenAndTargets :: BreakableCallChainEntry ( bcce) ]
303+ out . push ( ConcreteLineTokenAndTargets :: BreakableCallChainEntry ( bcce) ) ;
305304 }
306305 }
307306 }
308307
309- fn shimmy_and_shake_heredocs (
308+ fn write_heredocs (
310309 heredoc_strings : Option < Vec < HeredocString > > ,
311- ) -> Vec < ConcreteLineTokenAndTargets < ' src > > {
312- let mut res = vec ! [ ] ;
310+ out : & mut Vec < ConcreteLineTokenAndTargets < ' src > > ,
311+ ) {
313312 if let Some ( values) = heredoc_strings {
314313 for hds in values {
315314 let indent = hds. indent ;
@@ -318,19 +317,18 @@ impl<'src> AbstractLineToken<'src> {
318317
319318 let s = hds. render_as_string ( ) ;
320319 if !s. is_empty ( ) {
321- res . push ( clats_direct_part ( s) ) ;
322- res . push ( cltats_hard_newline ( ) ) ;
320+ out . push ( clats_direct_part ( s) ) ;
321+ out . push ( cltats_hard_newline ( ) ) ;
323322 }
324323 if !kind. is_bare ( ) {
325- res . push ( clats_indent ( indent) ) ;
324+ out . push ( clats_indent ( indent) ) ;
326325 }
327- res . push ( clats_heredoc_close ( symbol) ) ;
328- res . push ( cltats_hard_newline ( ) ) ;
326+ out . push ( clats_heredoc_close ( symbol) ) ;
327+ out . push ( cltats_hard_newline ( ) ) ;
329328 let indent_depth = if indent != 0 { indent - 2 } else { indent } ;
330- res . push ( clats_indent ( indent_depth) ) ;
329+ out . push ( clats_indent ( indent_depth) ) ;
331330 }
332331 }
333- res
334332 }
335333
336334 pub fn is_comment ( & self ) -> bool {
0 commit comments