Create Expr::to_pretty in mono IR

This commit is contained in:
Brian Carroll 2021-11-30 09:40:50 +00:00
parent 079a8311ec
commit c2a2ff2957
2 changed files with 13 additions and 0 deletions

View file

@ -1595,6 +1595,17 @@ impl<'a> Expr<'a> {
.append(symbol_to_doc(alloc, *structure)),
}
}
pub fn to_pretty(&self, width: usize) -> String {
let allocator = BoxAllocator;
let mut w = std::vec::Vec::new();
self.to_doc::<_, ()>(&allocator)
.1
.render(width, &mut w)
.unwrap();
w.push(b'\n');
String::from_utf8(w).unwrap()
}
}
impl<'a> Stmt<'a> {