Tuples of size 0 are unit elements (tt)
@@ -83,11 +83,14 @@ fn make_uint_size_coercion<'a>(pat: RcDoc<'a, ()>) -> RcDoc<'a, ()> {
}
fn make_tuple<'a, I: IntoIterator<Item = RcDoc<'a, ()>>>(args: I) -> RcDoc<'a, ()> {
- RcDoc::as_string("(")
+ let iter = args.into_iter();
+ match &iter.size_hint().1 {
+ Some(0) => RcDoc::as_string("tt"),
+ _ => RcDoc::as_string("(")
.append(
RcDoc::line_()
.append(RcDoc::intersperse(
- args.into_iter(),
+ iter,
RcDoc::as_string(",").append(RcDoc::line()),
))
.group()
@@ -95,7 +98,8 @@ fn make_tuple<'a, I: IntoIterator<Item = RcDoc<'a, ()>>>(args: I) -> RcDoc<'a, (
)
.append(RcDoc::line_())
.append(RcDoc::as_string(")"))
- .group()
+ .group(),
+ }
}
fn make_list<'a, I: IntoIterator<Item = RcDoc<'a, ()>>>(args: I) -> RcDoc<'a, ()> {
