@@ -19,8 +19,9 @@ use super::{
19
19
tag:: { DedentMode , GroupMode , LabelId } ,
20
20
* ,
21
21
} ,
22
+ separated:: FormatSeparatedIter ,
22
23
} ;
23
- use crate :: write;
24
+ use crate :: { TrailingSeparator , write} ;
24
25
25
26
/// A line break that only gets printed if the enclosing `Group` doesn't fit on a single line.
26
27
///
@@ -2390,6 +2391,26 @@ where
2390
2391
self
2391
2392
}
2392
2393
2394
+ pub fn entries_with_trailing_separator < F , I > (
2395
+ & mut self ,
2396
+ entries : I ,
2397
+ separator : & ' static str ,
2398
+ trailing_separator : TrailingSeparator ,
2399
+ ) -> & mut Self
2400
+ where
2401
+ F : Format < ' ast > + GetSpan ,
2402
+ I : IntoIterator < Item = F > ,
2403
+ {
2404
+ let iter = FormatSeparatedIter :: new ( entries. into_iter ( ) , separator)
2405
+ . with_trailing_separator ( trailing_separator) ;
2406
+
2407
+ for entry in iter {
2408
+ self . entry ( & entry) ;
2409
+ }
2410
+
2411
+ self
2412
+ }
2413
+
2393
2414
/// Finishes the output and returns any error encountered.
2394
2415
pub fn finish ( & mut self ) -> FormatResult < ( ) > {
2395
2416
self . result
@@ -2443,14 +2464,33 @@ where
2443
2464
pub fn entries < ' a , F , I > ( & mut self , entries : I ) -> & mut Self
2444
2465
where
2445
2466
F : Format < ' ast > + GetSpan + ' a ,
2446
- I : IntoIterator < Item = & ' a F > ,
2467
+ I : IntoIterator < Item = F > ,
2447
2468
{
2448
2469
for content in entries {
2449
2470
self . entry ( content. span ( ) , & content) ;
2450
2471
}
2451
2472
self
2452
2473
}
2453
2474
2475
+ pub fn entries_with_trailing_separator < ' a , F , I > (
2476
+ & mut self ,
2477
+ entries : I ,
2478
+ separator : & ' static str ,
2479
+ trailing_separator : TrailingSeparator ,
2480
+ ) -> & mut Self
2481
+ where
2482
+ F : Format < ' ast > + GetSpan + ' a ,
2483
+ I : IntoIterator < Item = F > ,
2484
+ {
2485
+ let iter = FormatSeparatedIter :: new ( entries. into_iter ( ) , separator)
2486
+ . with_trailing_separator ( trailing_separator) ;
2487
+
2488
+ for content in iter {
2489
+ self . entry ( content. span ( ) , & content) ;
2490
+ }
2491
+ self
2492
+ }
2493
+
2454
2494
pub fn finish ( & mut self ) -> FormatResult < ( ) > {
2455
2495
self . result
2456
2496
}
0 commit comments