Include trailing newline in pretty print output

This commit is contained in:
Joscha 2022-11-22 23:13:08 +01:00
parent af4311ba98
commit 802d776f29
2 changed files with 4 additions and 2 deletions

View file

@ -80,7 +80,7 @@ fn main() -> anyhow::Result<()> {
.parse(stream) .parse(stream)
.map_err(|e| anyhow!("{e:?}"))?; .map_err(|e| anyhow!("{e:?}"))?;
println!("{}", pretty::pretty_to_string(program, 100)); print!("{}", pretty::pretty_to_string(program, 100));
} }
Command::Desugar { Command::Desugar {

View file

@ -21,5 +21,7 @@ pub fn pretty_to_string<P: Pretty<'static, RcAllocator>>(p: P, width: usize) ->
p.pretty(&RcAllocator) p.pretty(&RcAllocator)
.render(width, &mut out) .render(width, &mut out)
.expect("p could not be rendered"); .expect("p could not be rendered");
String::from_utf8(out).expect("p created non-utf8 string") let mut s = String::from_utf8(out).expect("p created non-utf8 string");
s.push('\n');
s
} }