@@ -371,11 +371,7 @@ impl<'a> SourceMap<'a> {
371371 & ' b self ,
372372 mut patches : Vec < Patch < ' b > > ,
373373 fold : bool ,
374- ) -> Vec < (
375- String ,
376- Vec < TrimmedPatch < ' b > > ,
377- Vec < Vec < SubstitutionHighlight > > ,
378- ) > {
374+ ) -> Option < SplicedLines < ' b > > {
379375 fn push_trailing (
380376 buf : & mut String ,
381377 line_opt : Option < & str > ,
@@ -432,12 +428,8 @@ impl<'a> SourceMap<'a> {
432428
433429 // Find the bounding span.
434430 let ( lo, hi) = if fold {
435- let Some ( lo) = patches. iter ( ) . map ( |p| p. span . start ) . min ( ) else {
436- return Vec :: new ( ) ;
437- } ;
438- let Some ( hi) = patches. iter ( ) . map ( |p| p. span . end ) . max ( ) else {
439- return Vec :: new ( ) ;
440- } ;
431+ let lo = patches. iter ( ) . map ( |p| p. span . start ) . min ( ) ?;
432+ let hi = patches. iter ( ) . map ( |p| p. span . end ) . max ( ) ?;
441433 ( lo, hi)
442434 } else {
443435 ( 0 , source_len)
@@ -561,9 +553,9 @@ impl<'a> SourceMap<'a> {
561553 buf. pop ( ) ;
562554 }
563555 if highlights. iter ( ) . all ( |parts| parts. is_empty ( ) ) {
564- Vec :: new ( )
556+ None
565557 } else {
566- vec ! [ ( buf, trimmed_patches, highlights) ]
558+ Some ( ( buf, trimmed_patches, highlights) )
567559 }
568560 }
569561}
@@ -720,6 +712,12 @@ impl<'a> Iterator for CursorLines<'a> {
720712 }
721713}
722714
715+ pub ( crate ) type SplicedLines < ' a > = (
716+ String ,
717+ Vec < TrimmedPatch < ' a > > ,
718+ Vec < Vec < SubstitutionHighlight > > ,
719+ ) ;
720+
723721/// Used to translate between `Span`s and byte positions within a single output line in highlighted
724722/// code of structured suggestions.
725723#[ derive( Debug , Clone , Copy ) ]
0 commit comments