Fix pretty printing of empty BoundedSeparated
This commit is contained in:
parent
94ea196933
commit
74d1f640b5
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use pretty::{DocAllocator, DocBuilder, Pretty};
|
use pretty::{DocAllocator, DocBuilder, Pretty};
|
||||||
|
|
||||||
use crate::ast::{BoundedSeparated, Ident};
|
use crate::ast::{BoundedSeparated, Ident, Space};
|
||||||
|
|
||||||
use super::NEST_DEPTH;
|
use super::NEST_DEPTH;
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ impl<E> BoundedSeparated<E> {
|
||||||
D::Doc: Clone,
|
D::Doc: Clone,
|
||||||
FE: Fn(E) -> DocBuilder<'a, D>,
|
FE: Fn(E) -> DocBuilder<'a, D>,
|
||||||
{
|
{
|
||||||
|
let elems_empty = self.elems.is_empty();
|
||||||
allocator
|
allocator
|
||||||
.intersperse(
|
.intersperse(
|
||||||
self.elems
|
self.elems
|
||||||
|
|
@ -31,7 +32,7 @@ impl<E> BoundedSeparated<E> {
|
||||||
.map(|(s0, elem, s1)| allocator.line().append(elem_pretty(elem))),
|
.map(|(s0, elem, s1)| allocator.line().append(elem_pretty(elem))),
|
||||||
separator.clone(),
|
separator.clone(),
|
||||||
)
|
)
|
||||||
.append(self.trailing.map(|s| separator))
|
.append(self.trailing.filter(|_| !elems_empty).map(|s| separator))
|
||||||
.nest(NEST_DEPTH)
|
.nest(NEST_DEPTH)
|
||||||
.append(allocator.line())
|
.append(allocator.line())
|
||||||
.enclose(start, end)
|
.enclose(start, end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue